|Information on dispatch-techniques email@example.com (Alexander Kjeldaas) (1996-10-30)|
|Re: Information on dispatch-techniques firstname.lastname@example.org (Christian von Roques) (1996-11-03)|
|Re: Information on dispatch-techniques email@example.com (Nick Kramer) (1996-11-05)|
|Re: Information on dispatch-techniques firstname.lastname@example.org (1996-11-07)|
|Re: Information on dispatch-techniques email@example.com (Alexander Kjeldaas) (1996-11-26)|
|From:||Nick Kramer <firstname.lastname@example.org>|
|Date:||5 Nov 1996 23:33:49 -0500|
|Organization:||School of Computer Science, Carnegie Mellon|
Christian von Roques <email@example.com> wrote:
> * Each function T.f corresponds to a number `f'. At the same offset
> in all objects of type `t' is a pointer to a dispatch-table `d_t'
> which holds the address a = d_t[f].
This is the standard technique for implementing virtual functions in
C++. This "class first" scheme has one big advantage over the
"functions first" scheme (a = d_f[t]) in that it is easy to implement
using a standard C linker. Bjarne Stroustrup's "The Design and
Evolution of C++" describes all this in detail, although it's
scattered throughout the book. (Look under "virtual" in the index)
Presumably this class first technique is also used for implementing
method dispatch in Java. How, then, are "interface" methods
There are also languages with more complicated dispatch mechanisms.
In Dylan and CLOS (Common Lisp Object System), things are considerably
more complicated: You can dispatch off more than one parameter
(multi-methods), and you can specialize methods on types that are not
classes (such as union types and singleton types). In Dylan, a full
generic dispath means finding all applicable methods, sorting them,
and invoking the "most applicable" one. There's a lot of caching
going on, but even so a full generic dispatch is expensive enough that
compilers go to great lengths to avoid them.
(I've seen a lot more papers on caching schemes and on optimizing away
runtime dispatch than I have seen papers on actually implementing the
dispatch. Am I just looking in the wrong places?)
Return to the
Search the comp.compilers archives again.