Making "super" work outside a literal?

Brendan Eich brendan at
Sat Jun 25 13:49:16 PDT 2011

On Jun 25, 2011, at 11:13 AM, Axel Rauschmayer wrote:

> I don’t know if this has been discussed, but I find the |super| work-around provided by YUI and CoffeeScript (in the generated code) not that bad:
>, arg1, arg2);

I'm not sure what you mean. If we add 'super', surely we want more than the __super__ hack. We also want a callable expression 'super' in constructors, and a '' form for method and other property accesses from subclass methods. We don't want people writing out .call by hand.

> With ThisClass.__super__ pointing to SuperClass.prototype.

The CoffeeScript compiler can lexically bind ThisClass and wire up __super__ with generated runtime helper code. That's all backstage of the CoffeeScript *language*, though.

> As a completely static solution, one could maybe expand a super-call
>, y);
> to
>        __CurrentObject__.[[Prototype]], x, y);
> On the other hand, I don’t know if a reference to __CurrentObject__ is ever available for some kind of static expansion.

Are you talking about |here| again, with a new name? There is no static counterpart other than the one Allen proposed, the object literal directly containing the method that uses 'super'.


More information about the es-discuss mailing list