generic functions

Rainer Blome
Thu, 20 Jul 1995 21:25:05 +0200

> Having a generic function reifies (makes into an object) the dispatch
> technique. This is good for reflexion because you can then observe,
> modify and create new dispatch techniques.

true.  true.  true.

but how to find the function?  where is it located?  in what
context/namespace?  in an object, *dammit*.  and since i found it in an
object, i can save at least this one dispatch (if i already have the object
and the compiler is smart enough to bind the call/send early).

_that_ is what i am talking about.

> So I disagree that single argument dispatch is more efficient.

efficiency in the single argument case depends on how many cases have to be
checked.  with generic functions it's the number of different types.  with
message passing, it's the number of attributes the object has.  in both
cases, a dynamic compiler can cache the decision most of the time.

> And chaining single arguement dispatches is a mess.

no need to when "generic methods" exist.

> Finally, modularity and reuse suggest solving the problem once and
> making it available in the form of a generic function instead of
> dealing with multiple dipatch every time you need it.

true.  true.  true.

quote from my last message to the misa list:

"generic functions are the opposite of location specific [modular].  they
remove (possibly similar) behavior from a set of objects (the locations)
and put it all in a new `central' object (the gf), `local' only to itself."

(Note that the argument returns to the top of my message ;-)