Referencing `super`

Axel Rauschmayer axel at rauschma.de
Wed Aug 6 12:34:49 PDT 2014


On 06 Aug 2014, at 21:03 , Brendan Eich <brendan at mozilla.org> wrote:

> Rick Waldron wrote:
>> 
>>    I'm cool with super() in methods, I forgot we disallowed naked
>>    `super`, and my gut says we would support it as equivalent to `this`.
>> 
>> 
>> To clarify, you don't mean `super === this`, right?
> 
> The alternative is for bare `super` to denote the same-named superclass method bound to `this`. That enables the equivalence Allen wrote based on Brett's error citation:
> 
>    let superSubmit2 = super; // Error: "Unexpected token ;"
>    superSubmit2(); // if no Error, this is equivalent to super()
> 
> But that breaks the other equivalence:
> 
>    super.method();  ====  do { let s = super; s.method(); }
> 
> So you can see why bare `super` is currently illegal! (Want a better error message than the one Brett showed.)
> 
> If we make bare `super` an error for now, in hopes of resolving this conflict of equivalences later, which way do we think we'll resolve? We ought to have an opinion now.


Given how much `super` does under the hood (if you call a method, you get a super/this hybrid), a stand-alone `super` may give people the wrong idea (and I don’t see how it would be useful). It may be better to provide access to [[HomeObject]] (via Reflect?).

-- 
Dr. Axel Rauschmayer
axel at rauschma.de
rauschma.de



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140806/e36ed9b1/attachment.html>


More information about the es-discuss mailing list