Exactly! One way to do this is to give methods an implicit parameter "here" (the object in which a method was found during dispatch), in addition to "this".
Then super.foo(x, y) would desugar to Object.getPrototypeOf(here).foo.call(this, x, y) With call() and apply(), you would have here === this. Axel On Jun 19, 2011, at 19:44 , Peter Michaux wrote: > On Sun, Jun 19, 2011 at 10:20 AM, Axel Rauschmayer <a...@rauschma.de> 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. > > So you want "super" to be dynamic but tied to the value of "this" > inside that function? Something like... > > function fn() { > return this.alpha + super.beta(); > } > > function Foo() {} > Foo.prototype.alpha = function() {return 1;}; > Foo.prototype.beta = function() {return 2;}; > > function Bar() {} > Bar.prototype = Object.create(Foo.prototype); > Bar.prototype.beta = function() {return 5;}; > > var b = new Bar(); > fn.call(b); // 1 + 2 = 3 > > Peter > -- 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