Making "super" work outside a literal?
brendan at mozilla.com
Sun Jun 19 12:14:51 PDT 2011
On Jun 19, 2011, at 10:20 AM, Axel Rauschmayer wrote:
> It would be nice if "super" could work in any method and not just those methods that are defined inside an object literal. Then, a method would have to know what object it resides in, e.g. via an implicit parameter.
We wish to avoid another parameter computed potentially differently for each call. It will cost, and it will lead to surprises.
Also, anything reachable from |this| can be computed using ES5's Object.* APIs.
Quoting from http://wiki.ecmascript.org/doku.php?id=harmony:object_initialiser_super :
> When a function contains a reference to super, that function internally captures an internal reference to the [[Prototype]] of the object created by the enclosing object initialiser. If such a function is subsequently extracted from the original object and installed as a property value in some other object, the internal reference to the original [[Prototype]] is not modified. Essentially, when a function references super it is statically referencing a specific object that is identified when the function is defined and not the [[Prototype]] of the object from which the function was most recently retrieved.
> This behavior is consistent with that of most other languages that provide reflection function to extract methods containing super and then independently invoke them.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss