Re: Specializing slot-value-using-class in OpenMCL
- From: Pascal Costanza <pc@xxxxxxxxx>
- Date: Wed, 30 May 2007 16:35:51 +0200
Slava Akhmechet wrote:
I am trying to add custom behavior to slot access by specializing
slot-value-using-class. Specifically, I want to add classes whose slot
values have been modified to a list of "dirty" classes. My code works
properly on SBCL but I run into problems on OpenMCL.
As mentioned elsewhere, OpenMCL optimizes away slot-value-using-class
within let forms[1]. I wasn't able to find any information about
turning off this optimization. Lispworks provides
':optimize-slot-access' option in class definition, is there something
similar in OpenMCL?
Elephant seems to support OpenMCL, so there must be a way to do
this. Unfortunately it seems that information is rather scarce.
One hint: When you specializer slot-value-using-class (and the other slot access functions), you have to make sure that at least either the class or the slot definition parameter is specialized. It is not enough to only specialize the object parameter. So for example, the following is incorrect:
(defmethod slot-value-using-class
(class (object myclass) slotd)
...)
You should at least do this:
(defmethod slot-value-using-class
((class mymetaclass) object slotd)
...)
Unfortunately, the wording in the CLOS MOP specification is imprecise here, but OpenMCL is one of the implementations that interprets it like that. So OpenMCL optimizes away calls to slot-value-using-class when neither the class nor the slot definition parameter are specialized, and doesn't make any effort to check for specialization of the object parameter. (For example, SBCL doesn't perform this kind of optimization, that's why your code works there.)
IMHO, the CLOS MOP specification should drop this requirement, but that's a different story.
Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
.
- Follow-Ups:
- Re: Specializing slot-value-using-class in OpenMCL
- From: Slava Akhmechet
- Re: Specializing slot-value-using-class in OpenMCL
- References:
- Specializing slot-value-using-class in OpenMCL
- From: Slava Akhmechet
- Specializing slot-value-using-class in OpenMCL
- Prev by Date: Specializing slot-value-using-class in OpenMCL
- Next by Date: Re: Specializing slot-value-using-class in OpenMCL
- Previous by thread: Specializing slot-value-using-class in OpenMCL
- Next by thread: Re: Specializing slot-value-using-class in OpenMCL
- Index(es):