Super-references

Andrea Giammarchi andrea.giammarchi at gmail.com
Fri Mar 8 23:14:36 PST 2013


I CAN find super via this, the qwhole point about caller since this morning
was about the fact I could do stuff I cannot do anymore.

That said, in 2010:
http://webreflection.blogspot.com/2010/01/javascript-super-bullshit.html

late 2009 wrote early 2010:
http://webreflection.blogspot.com/2010/01/better-javascript-classes.html

And benchmark about all this in February 2009:
http://webreflection.blogspot.com/2009/02/on-javascript-inheritance-performance.html

So, just in case, have an extra look too on what developers wrote before
your blog did, thank you.

Thanks for your examples in any case.




On Fri, Mar 8, 2013 at 8:13 PM, Axel Rauschmayer <axel at rauschma.de> wrote:

> let me reformulate .. do you realize Object,mixing can be done runtime, so
> not possible to predefine the super, and that you method fails if you have
> more than a super in such form ? If not, can you write B extends A and C
> extends B and use super in both C and B methods going up to A or do what my
> example was doing ?
>
>
> You don’t predefine super, you only have to keep [[HomeObject]] updated.
> That’s what Object.mixin does. Then [[HomeObject]] (or rather, its
> prototype) is the starting point for looking for super-properties.
>
>
> Even easier, something like this:
>
> function A() {
>   this.test('Hello!');
> }
> A.prototype.test = function (what) {
>   alert(what);
> };
>
> function B() {
>   this.super();
> }
> B.prototype = poo.inherit(A.prototype);
> B.prototype.constructor = B;
> B.prototype.test = function (what) {
>   this.super(what);
> };
>
> poo.superable(B.prototype);
>
> new B;
> // will alert Hello! dong these steps:
> //  1. invokes B.prototype.constructor which
> //  2. invokes A.prototype.constructor which
> //  3. invokes B.prototype.test which
> //  4. invokes A.prototype.test
>
>
>
> Yes, that will work. But you can’t find `super` via `this` (which changes
> dynamically), you must start your search in the prototype of the object in
> which a method is stored.
>
> --
> Dr. Axel Rauschmayer
> axel at rauschma.de
>
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130308/b3bc0354/attachment.html>


More information about the es-discuss mailing list