Re: Overloading function calls

Marc Wachowitz (mw@ipx2.rz.uni-mannheim.de)
1 Jun 1994 12:28:55 GMT

Tim Peters (tim@ksr.com) wrote:
[...]
> So I haven't yet thought of something reasonable enough to suggest
> (despite that I thought I did last time I wrote <wink/sigh>).

I guess it wouldn't be reasonable to suggest something like dispatching
on both argument types of operators? Maybe we could even invent it; the
treatment of syntactic operators is already a special case, anyway ;-)

The idea is that one (in a yet to be described way) announces that some
operator's multi-method is a particular function for a particular order
of argument types. The central registration facility checks consistency
and dispatches the operator to the most appropriate function.

If no function for a particular operator exists, a general multi-method
would be called for coercion, and the process starts again on the tuple
which that function returns. Obviously the conversion function ought to
take care not to cause infinite loops (the dispatcher might check this,
by registering the type-pairs for a particular call, and scream if some
coercion returns a pair which was already there).

Yes, it's more complex to implement it, but once it's done, it's simple
and flexible.

------------------------------------------------------------------------------
* wonder everyday * nothing in particular * all is special *
Marc Wachowitz <mw@ipx2.rz.uni-mannheim.de>