Brendan Eich-3 wrote:
>
> 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.
>>
>
>
It's most sane proposal I think. However few things are not obvious to me,
will following evaluate as I assume:
var A = {
one: function () {
return 'A.foo';
}
};
var B = Object.create(A);
var C = Object.create(B);
C.one = function () {
return super.one();
};
var c1 = Object.create(C);
obj.one(); // 'A.foo'
B.two = function () {
this.three();
};
B.three = function () {
return 'B.three';
};
C.two = function () {
super.two();
};
C.three = function () {
return 'C.three';
};
var c2 = Object.create(C);
c2.two(); // C.three
Thanks!
-----
Mariusz Nowak
https://github.com/medikoo
--
View this message in context:
http://old.nabble.com/Making-%22super%22-work-outside-a-literal--tp31880450p31884964.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at
Nabble.com.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss