On Jun 23, 2011, at 10:39 PM, Axel Rauschmayer wrote: >>> Related topic: How would |super| be handled if |this| is lexical? >> >> There's no connection, AFAIK. But we also don't have a lexical-this proposal >> in Harmony yet. > > I would expect problems that are similar to that = this: > > var obj = { > mymethod: function(arr) { > arr.forEach(function(x) { > super.mymethod(x); // would this work? > }); > } > }
From http://wiki.ecmascript.org/doku.php?id=harmony:object_initialiser_super : PrimaryExpression : ... super The value of super is the same as the value of this but when super is used as the base of a property access the property lookup starts with the object that is the prototype of the object defined by the object literal that contains the reference to super. This seems to say that the wrong |this| would be used, with the right property lookup starting point. Yikes. > Thankfully, I don’t think that super-calls will be very common in typical > JavaScript code, in contrast to "this". Not sure this will all pan out as proposed. 'super' in classes works. 'super' in any function nested however deeply in an object initialiser, perhaps not. If the above spec constrained the nesting to be immedate method of, that would seem to solve it. But would that be too restrictive? /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