Making "super" work outside a literal?
brendan at mozilla.com
Sat Jun 25 14:10:44 PDT 2011
On Jun 25, 2011, at 2:05 PM, Axel Rauschmayer wrote:
> - __CurrentObject__ (or possibly a better name): Static, only available inside an object literal.
This is not proposed, and we don't want to require Object.getPrototypeOf(__CurrentObject__), or any name with the evil __ bracketing, for that matter. What is proposed, static super + defineMethod to clone the method into a new object with a rebound 'super', is enough.
>> There is no static counterpart other than the one Allen proposed, the object literal directly containing the method that uses 'super'.
> That would be enough. I guess I’m suggesting then to implement “super” like CoffeeScript does. Wouldn’t that be simpler?
As my next message showed, Allen's http://wiki.ecmascript.org/doku.php?id=harmony:object_initialiser_super is like CoffeScript as far as dynamic vs. lexical binding goes.
It differs in the same way that the Harmony classes proposal differs from CoffeeScript: you call super.foo() or super.bar() from method foo. You cannot just call super() from method foo to invoke the superclass's method foo, and only that method.
Should we really constrain super calls in methods to be only of the same-named method in the superclass? Conciseness is better but the restriction seems worse. Is it necessary in Ruby or CoffeeScript?
More information about the es-discuss