Minimalist Classes

Jeremy Ashkenas jashkenas at
Tue Nov 1 11:48:28 PDT 2011

On Tue, Nov 1, 2011 at 2:21 PM, Axel Rauschmayer <axel at> wrote:

> Invocation: 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.

> Would work? As far as I can tell, your bookkeeping works for one
> super recursion only, not for two.

Yes, would work. You can keep track of the super() depth
per-object-per-method ... and even for fancier cases where you restart the
same super() chain recursively from the outside. Imagine if one of the
deeper's itself calls, with a direct reference to the
instance (and a different parameter, to avoid infinite recursion). You can
imagine super counters as a stack instead of a value, and push a fresh one
on, popping it when the new call exits.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list