On Jun 19, 2011, at 12:54 PM, Axel Rauschmayer wrote:

> Makes sense.
> 
> 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.

No, that doesn't work. Both for cases where the function author really did mean 
the proto-object of the literal-induced object surrounding the function, and in 
efficiency terms (we do not mutate the RHS of assignment depending on the LHS's 
Reference Base, e.g.).

If you really want to change what super means in a function expressed in an 
object initialiser, I'd like to see the exact use-case.


> 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).

Assignments to properties is often more expensive, though (I know the Closure 
library prefers this style but it is the exception).

Trailing comma in object initialiser is fine in ES5-conforming engines.

/be

> 
> Axel
> 
> 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.
>>> 
>> 
>> /be 
>> 
>> 
> 
> -- 
> Dr. Axel Rauschmayer
> 
> a...@rauschma.de
> twitter.com/rauschma
> 
> home: rauschma.de
> blog: 2ality.com
> 
> 
> 

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to