Re: Multi-method (Hans Aberg)
6 Apr 2002 22:49:05 -0500

          From comp.compilers

Related articles
Multi-method (Jean-Marc Bourguet) (2002-03-31)
Re: Multi-method (2002-04-06)
Re: Multi-method (2002-04-06)
Re: Multi-method (Joachim Durchholz) (2002-04-06)
Re: Multi-method (Jean-Marc Bourguet) (2002-04-07)
Re: Multi-method (Jean-Marc Bourguet) (2002-04-07)
Re: Multi-method (Dmitry A.Kazakov) (2002-04-07)
Re: Multi-method (Joachim Durchholz) (2002-04-07)
[1 later articles]
| List of all articles for this month |

From: (Hans Aberg)
Newsgroups: comp.compilers
Date: 6 Apr 2002 22:49:05 -0500
Organization: Mathematics
References: 02-03-190
Keywords: OOP
Posted-Date: 06 Apr 2002 22:49:05 EST

  Jean-Marc Bourguet <> wrote:
>Is there such a technique allowing to dispatch on the type of several
> - in time proportionnal to the number of dispatching parameter
> - in such a way that independant compilation is possible.

I use a variation of "double dispatch" in order to create the effect of
runtime objects that can behave like that. (Actually, I first discovered
this technique independently, and found out that it is called double
dispatch. :-) )

Bjarne Stroustrup, "DEC++" has some discussions on multi-methods, sec. 13.8.

Double dispatch means that one first is calling the argument: If a runtime
objects f has a sequence of methods f.i, then an evaluation f(x) takes
place by first calling x.a(f), where x.a is a special "argument" method.

In the runtime model I have, every object has just one input, in effect,
just one variable then, but one can get around that by making use of list
objects for input. Thus, one treats f(x, y) as f([x, y]), or f getting a
reference to the list object [x, y].

As for the complexity, I found that by intelligently splitting up the
action on regular methods f.i and the argument method x.a, one can
actually decrease the number of methods needed quite radically. I have
implemented lambda calculus by use of this technique.

Thus, the problems of high complexity of multi-methods seem to depend on
that one links it to a certain variation of type theory, which pushes
forth a requirement of many methods.

    Hans Aberg * Anti-spam: remove "remove." from email address.
                                    * Email: Hans Aberg <>
                                    * Home Page: <>
                                    * AMS member listing: <>

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.