In my understanding, super would be null.
What would be more complex is :
var widget = {
hookup: function() {
// |this| is widget
// |super| is widget
window.addEventListener('load', function(event) {
// |this| is widget
// |super| ??
}.bind(this), false);
}
};
widget.hookup();
We have got a problem here because there’s no way to “keep” super working in an
asynchronous pattern. Well, you still can perform “var Super = super; .... {
... Super.foo(); ... } ...”
From: John J Barton
Sent: Saturday, October 01, 2011 5:51 PM
To: Brendan Eich
Cc: Axel Rauschmayer ; es-discuss
Subject: Re: Super-calls
On Sat, Oct 1, 2011 at 8:22 AM, Brendan Eich <[email protected]> wrote:
> On Oct 1, 2011, at 4:23 PM, Lasse Reichstein wrote:
>
> On Sat, Oct 1, 2011 at 2:16 PM, Axel Rauschmayer <[email protected]> wrote:
>>
>> Then a super-call is always about letting "this" stay the same, but
>> finding a "later" method: If your method lives in O1, you start your search
>> for the super-property *after* O1 etc. In code this looks as follows:
>> here.__proto__.foo.call(this, …)
>> where "here" means "the object that the current method lives in". The
>> effect is then:
>> - here.__proto__: start your search *after* the method’s object and look
>> for "foo".
>> - .call(this, …): but keep "this" the same.
>
> Am I right that super-calls only works for class methods, because they know
> the, statically determinable, prototype chain of its instances, and
> therefore it knows where to start the search.
> A normal method, e.g.,
> var o = {__proto__: { m: function(x) { alert(x); }};
> o.m = function(v) { super(v); }; // doesn't work
>
> You'd write super.m(v) there.
> See http://wiki.ecmascript.org/doku.php?id=harmony:object_initialiser_super
The idea sounds interesting but unfortunately reference is written in a
language I don't understand.
How about this case:
var widget = {
hookup: function() {
// |this| is widget
// |super| is widget
window.addEventListener('load', function(event) {
// |this| is NOT widget
// |super| ??
}, false);
}
};
widget.hookup();
jjb
> /be
>
> o.m("hello");
> won't be able to use "super", because it doesn't know where to start the
> search - all it knows is the this-argument to the call and the function
> itself, which doesn't necessarily mean anything.
> /L
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
--------------------------------------------------------------------------------
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss