Re: Multi-method

Jean-Marc Bourguet <jm@bourguet.org>
7 Apr 2002 12:36:53 -0400

          From comp.compilers

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)
Re: Multi-method rprogers@seanet.com (Richard Rogers) (2002-04-10)
| List of all articles for this month |
From: Jean-Marc Bourguet <jm@bourguet.org>
Newsgroups: comp.compilers
Date: 7 Apr 2002 12:36:53 -0400
Organization: Guest of ProXad - France
References: 02-03-190 02-04-022
Keywords: C++, OOP
Posted-Date: 07 Apr 2002 12:36:53 EDT

vbdis@aol.com (VBDis) writes:


> Jean-Marc Bourguet <jm@bourguet.org> schreibt:
>
> >In the first case, the use of "vtable" allows to have an efficient way
> >of making this dispatch, even in the context of separate compilation
> >(at the cost of constraining the possible types).
> >
>
> IMO the types here are not constrained.


A dispatching function can't select between an implementation for two
unrelated types, not even for two related types for which the common
ancestors are not valid types.


Yes, these constrains also allow static type checking but allowing to
do the type checking at run time will not remove all of them if you
want to implement dispatching with vtable indexed by an integer
(you'll have to make the vtable associative table indexed by the
function name).


Allowing the declaration of dispatching function outside the module
where the type is declared will also imply the possibility of adding
elements to the table or force its construction at link or start up
time.


> With multiple parameters C++ templates may be useful.


C++ template gives static polymorphism, multiple dispatch a dynamic
one. I fail to see how template can help in this context.


--
Jean-Marc


Post a followup to this message

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