Discussion: new operators for numerical computation

Greg Ewing see at my.signature
Wed Aug 2 00:58:13 EDT 2000


Edward Jason Riedy wrote:
> 
> Assume the generic function route to multiple dispatch...

I'm going to need a concrete example before I can see
how this works out. Suppose there is a type Wibble
and module Frobulation which provides a generic
function frobulate(x,y) and a method frobulate(Wibble,Wibble).

In module Frisbee, I import Frobulation and proceed
to frobulate some Wibbles. 

Now someone creates a class SuperWibble which inherits from
Wibble, and defines a method frobulate(SuperWibble, SuperWibble). 
Nobody tells me this, and I don't make any changes to what Frisbee
imports. But one day someone passes me some SuperWibbles
and I try to frobulate them.

What happens? Does frobulate(SuperWibble, SuperWibble)
get called? If so, how do I know this, and how do I
know where to look for its definition?

If it doesn't get called (i.e. I have to import the
specific method from somewhere) it doesn't seem much
more useful than static overloading.

> How is this significantly more painful than the object factory pattern?

The factory has control over what kinds of objects it creates,
and those objects in turn have control over what operations
can be done with them. But with generic functions and
multimethods, it seems like anyone anywhere can change the
meaning of anything anywhere else. That makes me uneasy.

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list