[Python-3000] [Fwd: features i'd like [Python 3000] ... #3: fix super()] (original) (raw)
Bill Janssen janssen at parc.com
Thu Dec 7 05:21:11 CET 2006
- Previous message: [Python-3000] [Fwd: features i'd like [Python 3000] ... #3: fix super()]
- Next message: [Python-3000] [Fwd: features i'd like [Python 3000] ... #3: fix super()]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 class:
try: method = super(cls, obj).method except AttributeError: pass else: 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.
http://www.archive.org/details/DanielGB1987
Bill
- Previous message: [Python-3000] [Fwd: features i'd like [Python 3000] ... #3: fix super()]
- Next message: [Python-3000] [Fwd: features i'd like [Python 3000] ... #3: fix super()]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]