Making "super" work outside a literal?

Sean Eagan seaneagan1 at gmail.com
Mon Jun 20 11:38:03 PDT 2011


I have also been working on a proposal to extend "super" to be
available anywhere by using a "super binding" concept similar to the
exising "this binding" concept, as well as taking ideas from [object
initialiser super].  It is a work in progress, any comments would be
much appreciated!

Please see: https://gist.github.com/1036200

[object initialiser super]
http://wiki.ecmascript.org/doku.php?id=harmony:object_initialiser_super

On Mon, Jun 20, 2011 at 6:49 AM, Mariusz Nowak
<medikoo+mozilla.org at medikoo.com> wrote:
>
>
>
> 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 at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
Sean Eagan


More information about the es-discuss mailing list