multi-dispatch (was Re: large class hierarchies in python)

Albert Langer Albert.Langer at Directory-Designs.Org
Tue Sep 18 01:44:31 EDT 2001


"Alex Martelli" <aleax at aleax.it> wrote in message news:<9nnndo02o24 at enews1.newsguy.com>...

> [...] Another characteristics of Dylan that we
> see in Python 2.2 at last (although I'm not sure whether
> Guido was aware of it or simply redesigned it anew) is a
> cleverer ordering of bases in a multiple-inheritance case
> where one or more base classes happen more than once (an
> "inheritance diamond" or similar topologies), with support
> for "walking" along bases classes in a systematic way
> (although the latter, with the 'super' built-in, is still
> rather syntactically unripe in Python 2.2 alpha 3, there IS
> hope that it may be better integrated before 2.2 gets
> released).

Guido references "Putting Metaclasses to Work" by Ira Forman
and Scott Danforth.

Also mentions that this relies on dynamically creating metaclasses
that are derived from the metaclasses of all the base classes and
this is too difficult for Python 2.2.

I tracked down some relevant papers (and java software) via Google, eg
at:

http://home.austin.rr.com/forman/ira/

These are useful for understanding the thinking behind Python 2.2
(though I imagine the book would be even more useful).

One of them mentions (p4) that "Similar arrangements of classes are
also used in CLOS[12], ObjVlisp[2], Dylan[1], and Pro-teus[16]."

http://www.parc.xerox.com/csl/groups/sda/projects/reflection96/docs/forman/forman.pdf

It isn't at all clear that this is specifically referring to the mro
for "diamonds".

Others mention that the mro is "depth first" but I still don't
understand this stuff well enough to be able to tell whether it
implies selecting the last repetition in a "diamond" rather than the
first. (This is certainly not very explicit as a result of the
dynamically derived metaclasses stuff and the
orientation towards java single inheritance).

Nevertheless I do recommend studying these papers (or the book) for
anyone else trying to understand the background. This stuff in 2.2 is
certainly going to have a major impact on how to do all sorts of
things and I would guess that a lot of the content of the book is also
in the various papers and tutorials.



More information about the Python-list mailing list