[Python-3000] [Fwd: features i'd like [Python 3000] ... #3: fix super()]
janssen at parc.com
Thu Dec 7 05:21:11 CET 2006
> I agree with you, but it makes it *very* difficult to write properly
> behaving cooperative super calls. In fact, if one inherits at any point
> from object, one must necessarily use the following pattern in every
> _method = super(cls, obj).method
> except AttributeError:
> result = _method(...)
> How is this reasonable or from an "I want to write correct code"
> standpoint? I would argue that it isn't reasonable, and is in fact
> insane. I don't want to write that, but to prevent AttributeErrors from
> cropping up in arbitrary locations, it is necessary.
I completely agree. Lisp has a function called "call-next-method",
which is used to invoke the next method logically in the inheritance
sequence. If there is no "next" method, it invokes another standard
function, "no-next-method", which you can override to ignore the call,
or provide a default, or whatever. And having to explicitly provide
"cls" and "self" is also grotty, but necessary because the call has no
handle on its context (hmmm, stack frames?).
Incidentally, the Internet Archive has a nice video by Danny Bobrow
up, which is a tour through the CLOS system, including some discussion
of the design rationale. Anyone interested in knowing more about
generic function implementations and class precedence determination
might be interested in watching it.
More information about the Python-3000