Related articles |
---|
Multi-method jm@bourguet.org (Jean-Marc Bourguet) (2002-03-31) |
Re: Multi-method haberg@matematik.su.se (2002-04-06) |
Re: Multi-method vbdis@aol.com (2002-04-06) |
Re: Multi-method joachim_d@gmx.de (Joachim Durchholz) (2002-04-06) |
Re: Multi-method jm@bourguet.org (Jean-Marc Bourguet) (2002-04-07) |
Re: Multi-method jm@bourguet.org (Jean-Marc Bourguet) (2002-04-07) |
Re: Multi-method mailbox@dmitry-kazakov.de (Dmitry A.Kazakov) (2002-04-07) |
Re: Multi-method joachim_d@gmx.de (Joachim Durchholz) (2002-04-07) |
[1 later articles] |
From: | haberg@matematik.su.se (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 <jm@bourguet.org> wrote:
>Is there such a technique allowing to dispatch on the type of several
>parameters
> - 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 <remove.haberg@member.ams.org>
* Home Page: <http://www.matematik.su.se/~haberg/>
* AMS member listing: <http://www.ams.org/cml/>
Return to the
comp.compilers page.
Search the
comp.compilers archives again.