> 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 _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com