Making "super" work outside a literal?
axel at rauschma.de
Sun Jun 19 12:54:10 PDT 2011
I don’t know how problematic this would be, but if "super" is an internal property of a function, then it could be updated whenever such a function is set as the value of a property.
I’m increasingly decomposing object literals into assignments to properties, especially if a literal is long (easier rearrangement of methods, because there is no need to avoid the trailing comma; context is clearer).
On Jun 19, 2011, at 21:14 , Brendan Eich wrote:
> 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.
Dr. Axel Rauschmayer
axel at rauschma.de
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss