Q: Python 2.0 preliminary features?

William Tanksley wtanksle at hawking.armored.net
Sat Oct 23 10:23:59 EDT 1999


On Wed, 20 Oct 1999 05:55:44 +1000, skaller wrote:
>William Tanksley wrote:
>> This is totally orthogonal to your post, but I'm just curious: I like how
>> Dylan allows one to write the first argument of a function either as a
>> distinguished or ordinary paramter -- that is, "abs(1)" is the same as
>> "(1).abs()".

>> Can we do the same with Viper?

>	No. I was going to implement it, but when I considered it,
>I realised it wouldn't work well in Python. The problem is 
>several fold: in the first place, there's nothing magical
>about function calls in python:

>		x.a (args)

>is really:
>	(x.a) (args)
>that is, an attribute lookup _followed_ by a function call.

Yes, I see.  This does make this syntax effectively impossible.  Okay,
just as well.

>So we would need to say that if
>	x.a
>fails, try looking for 'a'. Worse, consider:

Actually, you'd always define x.a when you defined a globally.  Not that
hard, just a huge waste of space and time :).

>Anyhow, it started to look seriously inconsistent in Python.

You know, I'd always thought of that as a problem with Python (although it
makes certain things simpler), but I just recently found the XML-RPC
client written in Python.  Because Python is not supposed to have
knowledge of objects' internals, the XML-RPC calls are direct -- you just
write "xml_object.method(...)" rather than having to quote the names of
the remote methods, as you have to do with every other XML-RPC API.

Cool.

>> 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.

>	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.

You can think of it as being like a combination of overloading and
templates, but resolvable at runtime.  Thus, it's MUCH more powerful
without being more risky -- in fact, it's less risky than most
implementations of overloading (C++'s especially).

>John Skaller, mailto:skaller at maxtal.com.au

-- 
-William "Billy" Tanksley




More information about the Python-list mailing list