python hack of the day -- "listable" functions

Gordon McMillan gmcm at hypernet.com
Sat May 15 17:25:01 EDT 1999


William Tanksley wrote:

> On Sat, 15 May 1999 18:01:10 GMT, Jim Meier wrote:

> >The language (if it cares) would
> >dispatch to the member function whose signature matched the parameters. This is
> >normal in many OO languages (C++ being the first to come to mind)
> 
> This is called "overloading", not polymorphism.  As a matter of
> fact, overloading makes OO _very_ difficult, and makes it easy to
> make bad mistakes which the compiler and runtime can't catch.
> 
> Overloading looks like multiple dispatch but isn't, just like static
> binding looks like OO but isn't.

Well, in a language like C++ or Java, "dispatch" normally shows up as 
a combination of overloading and overriding. The compiler can only 
handle one of those at a time, so the proper solution is to bounce 
the thing back and forth enough times that the language can resolve 
it.

The _usual_ solution is to hack it up with some run time type 
checking. For some reason using the term "dispatch" to a C++ or 
Java coder will only earn you a blank stare.

polymorphism-has-many-morphs-ly y'rs

- Gordon




More information about the Python-list mailing list