multi-method dispatch 
Author Message
 multi-method dispatch

I was wondering how "argument generalisation" happens in a multi-method
system. For example say I call,

        f(a,b)

where a:T1, b : T1.

Say there is no match of the signature <f,T1,T1>. Now how does the
dispatcher chose another signature to lookup on. For example how
would the dispatcher find,

        f(a,b)

where a:T2, b:T1, and T2 a superclass of T1.

I can think of several different dispatch strategies here corresponding
to various types of search over the inheritance graph. Are there
standard approaches which are better than others?

graham
--
                      Je suis pour le communisme
                      Je suis pour le socialisme
                      Je suis pour le capitalisme
                     Parce que je suis opportuniste



Sat, 16 Aug 1997 06:21:24 GMT  
 multi-method dispatch

Quote:

>I was wondering how "argument generalisation" happens in a multi-method
>system. For example say I call,
>    f(a,b)
>where a:T1, b : T1.
>Say there is no match of the signature <f,T1,T1>. Now how does the
>dispatcher chose another signature to lookup on. For example how
>would the dispatcher find,
>    f(a,b)
>where a:T2, b:T1, and T2 a superclass of T1.
>I can think of several different dispatch strategies here corresponding
>to various types of search over the inheritance graph. Are there
>standard approaches which are better than others?

There are several strategies.  The one I think best is
to require that there must be a unique most specific method
(in the pointwise extension of the subtype ordering)
that is a generalization of the classes of the actuals.
If such a method exists, you call it.  I think if it doesn't,
it should be an error (a type error).

Let's call this relation <=inh (in ASCII), as it's the pointwise
extension fo the inheritance relation on classes.

For example, if ColorTriple is a subclass of Triple,
and Triple is a subclass of Pair, then

        (ColorTriple, ColorTriple) <=inh (ColorTriple, Pair)
        (ColorTriple, ColorTriple) <=inh (Pair, ColorTriple)
        (Pair, ColorTriple) <=inh (Pair, Pair)

etc.  Then if we have a multi-method "equal" and a call

        equal(aColorTriple, anotherColorTriple)

then you call a specialized method for(ColorTriple, ColorTriple)
in preference to one specialized on the classes (ColorTriple, Pair),
because it's more specific.

You can fuss with linerizing the ordering, and you can go up the ordering
in case of conflict (as in the lambda-& calculus).  But it gets complicated,
and in any case the language is making arbitrary decisions for the programmer.

For details and references, see the following paper (pardon my HTML).

Craig Chambers and Gary T. Leavens.
Typechecking and Modules for Multi-Methods.
In <CITE>OOPSLA '94 Conference Proceedings</CITE>, pages 1--15.
Volume 29, number 10 of <CITE>ACM SIGPLAN Notices</CITE>, October 1994.
(A longer version is Department of Computer Science, Iowa State University,
<A HREF="file://ftp.cs.iastate.edu/pub/techreports/TR94-03/TR.ps.Z">
TR #94-03a</A>, March 1994, revised August 1994.)

There is also another paper on orderings for inheritance
at the 1994 OOPSLA that may be of interest...

        Gary Leavens
--
        229 Atanasoff Hall, Department of Computer Science

        phone: (515)294-1580 fax: (515)294-0258 ftp site: ftp.cs.iastate.edu
        URL: http://www.cs.iastate.edu/~leavens/homepage.html



Sat, 16 Aug 1997 12:09:39 GMT  
 multi-method dispatch

Quote:

>I was wondering how "argument generalisation" happens in a multi-method
>system. For example say I call,
>    f(a,b)
>where a:T1, b : T1.
>Say there is no match of the signature <f,T1,T1>. Now how does the
>dispatcher chose another signature to lookup on. [...]

Sounds interesting. But say, what is "multi-method dispatching"?  A
established notion? A new invention? I thought of something which
might match the notion years ago when I converted from OO to FP, but
never elaborated it seriously.

--



Sat, 16 Aug 1997 18:04:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. What is multimethod dispatch useful for.

2. Q: Can hash be used in OO multi-method dispatch?

3. not grasping the method overloading/multi-dispatch thing

4. Multi-methods, multi-polymorphism in python

5. Multiple dispatch / multimethods??

6. Q: Pointers on algorithms for multi-argument dispatch

7. method dispatch ?

8. simple method dispatch question

9. method dispatch for gwydion

10. method dispatch ?

11. Method Dispatch Ambiguity

12. method dispatch ?

 

 
Powered by phpBB® Forum Software