[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

direct-instance declarations



Sealed-classes provide a mechanism for reducing dispatching, but
unfortunately the current mechanism is limited in annoying ways.
First, dispatching is performed at compile-time for only
sealed-classes at the leaves of the class heterarchy.  This prevents
creating efficient instantiable classes with subclasses.  Secondly,
after sealing a class it is forbidden to create a new subclass for
that class.  This means, for example, that none of the code for the
classes in the sealed collection classes can be leverage -- for
example it is impossible to create a new <table> subclass with a
slight variation.

I have a proposal that I think would keep all the advantages of the
sealed-class mechanism while overcoming these limitations.  I propose
a new object declaration, which I call an ``direct'' declaration.  It
is a means for specifying that an object is a direct-instance of a
declared class, instead of a general-instance of a declared class.
This would allow a programmer to precisely specify a sealed-class with
subclasses and would permit the compiler to perform the dispatching.
Also it would permit a programmer to subclass an already sealed-class,
because the original sealed-class could be specified in a precise
manner.

The default declaration would be general-instance and thus the change
would be backward-compatible with the current design.  In order
to achieve the best performance, though, the programmer must employ a
new syntax for specifying the type of a variable or parameter.  A
proposed syntax would be `(direct <table>)' (as opposed to just
`<table>') and perhaps there would be a read macro to shorten the
syntax.  A similar design has been employed in the Sather language and
has been shown to dramatically reduce the amount of dispatching
(without overly restricting the programmer).

-- jonathan

IRCAM
31, rue Saint-Merri
F75004 Paris, France
011-33-1-42772492
bachrach@ircam.fr