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

Re: Attempting to circumvent Symbolics' Reader Method optimization

> Date: Tue, 7 Apr 1992 10:38-0500
> From: basham@aio.jsc.nasa.gov (Bryan Basham)
> I have written a piece of code that dependends on the reader methods to call
> SLOT-VALUE.  However, I have discovered that Symbolics' MOP performs an
> optimization (?) that does not call SLOT-VALUE.  I would like to circumvent
> the "empty" creation of Reader Methods and place a real method (that calls
> SLOT-VALUE in its place).

I don't believe there is anything in the specification that requires (or even 
implies) that the methods defined by DEFCLASS actually call SLOT-VALUE, and I 
believe this is intentional, as it permits some significant optimizations.  The 
whole point of the class STANDARD-READER-METHOD is that it permits the 
effective method computation to notice that the only applicable method is one 
whose definition is understood by the implementation, thereby allowing the 
access to be inlined in the effective method or even "hoisted" up into the 
generic function dispatcher.

[Note: While I have a fair amount of experience with implementing CLOS, I have 
no familiarity whatsoever with Symbolics' implementation.  The following 
suggestion should be considered with that caveat in mind.]

The way to circumvent this is to cause your metaclass to not use 
STANDARD-READER-METHOD for these methods, but to instead use some other method 
class that does the appropriate thing for your metaclass.  You might also be 
able to hook into the same protocol as used with STANDARD-READER-METHOD in 
order to implement any optimizations appropriate to your class of accessor 
methods.  Not being a Symbolics wizard, I don't know what generic functions you 
might need to specialize in order to get this effect.  I would probably start 
by looking for a function called something like add-reader-method.