Referencing `super`

Brendan Eich brendan at mozilla.org
Wed Aug 6 12:03:50 PDT 2014


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.

/be


More information about the es-discuss mailing list