[Openmcl-devel] Applying sequence functions to a new type

Raffael Cavallaro raffaelcavallaro at mac.com
Tue Mar 1 07:40:23 PST 2005


On Mar 1, 2005, at 9:34 AM, rm at fabula.de wrote:

> Is this a limitation of CLOS or an artefact of the implementation of 
> BUILT-
> IN-CLASSes?

This is a limitation of the ANSI spec. In order to allow implementors 
to optimize built in classes, they are not subclassable, redefinable, 
and instances may not change class. Remember that the ANSI Common Lisp 
spec is an attempt to balance dynamism with the ability to generate 
fast code.

from: <http://path/to/hyperspec/Body/t_built_.htm#built-in-class>
"A built-in class is a class whose instances have restricted 
capabilities or special representations. Attempting to use defclass to 
define subclasses of a built-in class signals an error of type error. 
Calling make-instance to create an instance of a built-in class signals 
an error of type error. Calling slot-value on an instance of a built-in 
class signals an error of type error. Redefining a built-in class or 
using change-class to change the class of an instance to or from a 
built-in class signals an error of type error. However, built-in 
classes can be used as parameter specializers in methods."

Another approach to this issue is the idea of sealing  - not present in 
Common Lisp, but a feature of Dylan, for example. If the programmer 
knows that s/he will not be subclassing a certain class s/he can make a 
sealed domain, slot, or method declaration. This allows the compiler to 
produce faster code, since no allowance for certain sorts of method 
dispatch need to be made, and other optimization possibilities open up:

from: <http://gauss.gwydiondylan.org/books/drm/drm_75.html#HEADING75-13>
"A define sealed domain definition accomplishes this by permitting the 
compiler to eliminate some of the known methods on a generic function 
from the set of methods that might be applicable to a particular call 
at runtime. For example, if this leaves exactly one applicable method, 
the compiler can eliminate a run-time method dispatch and consider 
additional optimizations such as inlining."

  Dylan has sealing, although it also has some built in classes which 
are not subclassable iirc. Goo is another attempt to have *full* 
dynamism with the ability to seal and get optimized generated code. I 
haven't looked at goo in a while, so I don't know how far Jonathan 
Bachrach has gotten with this yet.

regards,

Ralph

Raffael Cavallaro, Ph.D.
raffaelcavallaro at mac.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 2500 bytes
Desc: not available
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20050301/5ca2aa1d/attachment.bin>


More information about the Openmcl-devel mailing list