Minimalist Classes

Axel Rauschmayer axel at rauschma.de
Tue Nov 1 12:21:34 PDT 2011


> Invocation: B.describe.call(obj) should return "BA". With your library I would expect it to return "BBA".
> 
> Yes, it would. That's a good tricky case. I'm not sure if extra bookkeeping could make sense of that call, as there isn't any information as to where the function fits in to obj's prototype chain -- or if it's part of another prototype chain entirely. I'd like to hope that something could be figured out, but another alternative is for super() within a direct call() or apply() to be an error.

Another problem: What if an instance method makes a super-call?

A slightly less elegant (and performant) variant of your solution that works in both of the above cases is:

- Keep track (per object and method) of the object where the previous super-call (e.g. super.foo()) ended up.

- Start your search either there or at |this|: look for the *second* occurrence of property "foo". [optional: optimize non-|this| case]

-- 
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/20111101/c6745d01/attachment-0001.html>


More information about the es-discuss mailing list