[Ecls-list] Re: :optimize-slot-access

Juan Jose Garcia Ripoll lisp at arrakis.es
Wed Mar 22 02:37:00 UTC 2006


On Tue, 2006-03-21 at 15:27 -0500, Dan Corkill wrote:
> > 1) Supply (:optimize-slot-access nil) as an option to your DEFCLASS
> > forms.
> 
> This is not quite working in the latest CVS, as the optimize-slot-access 
> slot value will be (nil) rather than nil

I have fixed this and added a global variable to control the behavior of
this option, CLOS:*OPTIMIZE-SLOT-ACCESS*. It defaults to T, thus
providing you with the fast slot access that avoids using
slot-value-using-class. You can globally set it to NIL to get a more
AMOP compatible behavior. The code below has been tested with these
changes:

(defclass foo () ((a :initarg :a :accessor foo-a))
(:optimize-slot-access nil))
(defvar *a* (make-instance 'foo :a 2))
(print (foo-a *a*))
; => 2

(defmethod clos:slot-value-using-class ((class standard-class) (object
foo) slotd)
    (1+ (call-next-method)))
(print (foo-a *a*))
; => 3

(setf clos::*optimize-slot-access* nil)
(defclass foo () ((a :initarg :a :accessor foo-a)))
(print (foo-a *a*))
; => 3

(setf clos::*optimize-slot-access* t)
(defclass foo () ((a :initarg :a :accessor foo-a)))
(print (foo-a *a*))
; => 2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20060322/8f6b0f04/attachment.sig>


More information about the ecl-devel mailing list