Minimalist Classes

Jeremy Ashkenas jashkenas at gmail.com
Tue Nov 1 12:27:10 PDT 2011


On Tue, Nov 1, 2011 at 3:21 PM, Axel Rauschmayer <axel at rauschma.de> wrote:

>
> 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]
>

Nope -- I think that design isn't the correct semantics. super() exists to
delegate back to parent implementations of *the current method*. When
calling a different instance method the calls should always start back out
at the bottom of the inheritance hierarchy -- not at whatever level you
happened to be on at the time.

If you haven't overridden the other instance method, then everything will
work as expected ... and if you *have* overridden it, you need that
overridden implementation to be called, otherwise you're breaking all kinds
of expectations about the behavior of your code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111101/0cfdcf40/attachment.html>


More information about the es-discuss mailing list