Q: Python 2.0 preliminary features?

William Tanksley wtanksle at hawking.armored.net
Sun Oct 24 10:28:32 EDT 1999


On Sun, 24 Oct 1999 08:07:20 -0400, Gordon McMillan wrote:
>[William Tanksley]

>> >> Of course, I'm about to ask for multiple dispatch, but since
>> >> everyone who even knows what multiple dispatch is already knew
>> >> I was going to ask for it...  So I won't bother asking.

>[John Skaller] 
>> >	What do you want it to do? Any idea how it should work in
>> >Python?

>> Multiple dispatch.  Hmm...

>> Okay, the type of OO you're familiar with is also known as single
>> dispatch -- you take a message, a bunch of parameters, and a
>> special parameter (called 'this' or 'self'), and you look up the
>> meaning of the message in self's method table.

>> With multiple dispatch, OTOH, you take a message and a bunch of
>> parameters, and you look up the meaning of the message in the
>> message's parameter table.

>It's called "multiple dispatch" because, I think, you're 
>supposed to dispatch on both message and self/this.

Dear me, no.  I'm sorry I was unclear -- it's multiple dispatch because
you dispatch on every single parameter to the call, not just a special one
called 'this'.

>In C++ or Java, this shows up as trying to resolve both an 
>override and an overload at the same time. That is:

Nope -- although like using non-virtual functions in C++ to handle OO,
it's close so long as you don't ever inherit.

>Unfortunately, this means creating scores of virtual methods 
>with no purpose except allowing the compiler to find the trail.

No, it's just a different way of storing functions -- instead of storing
messages together with methods inside an object, you store the messages
globally and only the methods locally.

Of course, this is very different from how Python works now, so I actually
think it's not that good of an idea :-).  Python can be a good language
without having to use every good idea other language have -- that's what
Dylan is for.

>The real point being that before you ask for dual dispatch, 
>you'd better ask for overloading first...

Never!  Overloading is a certain way to break multiple dispatch.  MD can
handle everything overloading does, but it can also do it at runtime, the
way Python prefers to work.

Now, we WOULD need typed method declarations before we could use multiple
dispatch.

My judgement: not worth bothering.  It's really nice, but if I need it I
can always use CLOS.

>- Gordon

-- 
-William "Billy" Tanksley




More information about the Python-list mailing list