[Gd-hackers] Chinese Dispatch for Multimethods

Chris Page chris at chris-page.org
Fri Jan 4 21:33:23 CET 2008


On Jan 4, 2008, at 05:04 AM, Bruce Hoult wrote:

> Dylan has *only* virtual inheritance, though it's implemented a bit
> differently.  Fields from base classes are included only once in an
> object no matter how many times that base class is mentioned in the
> inheritance graph.  There is no need to offset the "this" pointer or
> to have internal pointers to the one instance of a base class's fields
> because field accessors are themselves virtual functions.


I should probably add: If you declare a class "primary" then its slots  
are accessible more efficiently. Only one chain of "primary"  
superclasses can be inherited in a multiple inheritance situation.

I usually describe it as the opposite of C++: You get virtual  
inheritance by default and explicitly declare primary ("non-virtual")  
inheritance. (Of course, that's a loose analogy.)

 From the DRM:

   <http://www.opendylan.org/books/drm/Declaring_Characteristics_of_Classes#IX-1111 
 >

   "An explicitly defined class may be declared to be either primary  
or free. The default is free. Each primary superclass of a class must  
be either a subclass or a superclass of all the other primary  
superclasses of the class. (This essentially restricts primary classes  
to forming a single inheritance chain.) Slots defined in a primary  
class may be accessed more efficiently than slots defined in a free  
class."

-- 
Chris Page - Dylan Programmer

  Open Source Dylan Compilers: <http://www.opendylan.org/>






More information about the hackers mailing list