Multiple dispatch (Re: Q: Python 2.0 preliminary features?)

Greg Ewing greg.ewing at compaq.com
Wed Oct 27 05:07:57 EDT 1999


Multiple dispatch is an attractive idea, but it makes me uneasy.
One reason is that it's not clear what the rules should be.

Suppose AA is a subclass of A, and BB is a subclass of B,
and there are methods defined for the combinations
foo(A, B), foo(AA, B) and foo(A, BB).

Now, if you make a call with the combination foo(AA, BB),
which method should get called?

Arbitrary rules can of course be invented, but there is
no single choice that is obviously "right" the way there
is with single dispatch.

Multiple inheritance has a similar problem, which is why
I'm not all that keen on it either, unless used in a very
restricted way.

If you have multiple dispatch *and* multiple inheritance,
things get just too hairy to contemplate. I tried to devise
a set of rules for this case once, but my brain got dangerously
close to exploding and I had to give up...

Greg




More information about the Python-list mailing list