Re: Multi-method

"Dmitry A.Kazakov" <>
7 Apr 2002 12:37:44 -0400

          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)
Re: Multi-method (Richard Rogers) (2002-04-10)
| List of all articles for this month |

From: "Dmitry A.Kazakov" <>
Newsgroups: comp.compilers
Date: 7 Apr 2002 12:37:44 -0400
Organization: Compilers Central
References: 02-03-190
Keywords: C++, OOP
Posted-Date: 07 Apr 2002 12:37:44 EDT

Jean-Marc Bourguet 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.

The first move would be getting rid of vtable. The dispatch table
should be associated rather with methods than with objects. For a
method with n dispatching parameters the dispatch table could be a
n-dimensional array of thunks. The type tag could be a pointer to the
type vector that for each method gives an index in the dispatch
table. Thus a dispatching call would require n x indexing the types'
vectors + indexing the method's dispath table.

The major problems are:

1. Maintaining the data structures supporting dispatch at run time.
Provided that overriding may occur in a nested block, consider:

function Funny (...) is
      type AA is new A ... -- A new type derived from A
      function Foo (...) -- Override some method Foo of A
      Object : AA;
      Foo (Object, ...); -- Dispatch to the local version of Foo
end Funny; -- Here AA is finalized and all effects should disappear

2. Freezing rules. Methods cannot be associated with just one type. Thus
they cannot be declared like in C++ within type declarations. The freezing
point in C++ is the closing } of the type declaration. One must relax this
rule, but not very loosely. Because arbitrary overrdinings are near to
impossible to maintain.

Dmitry Kazakov

Post a followup to this message

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