On Wed, Jan 05, 2011 at 06:15:34PM +0100, Didier Verna wrote: > > Tim Bradshaw pointed out that my message was not very clear because the > test I gave does not demonstrate that an initform's result is used to > initialize the slot early, only at which time a slot is initialized. > > This on the other hand gets closer to the point: > > (defclass test () > ((slot :allocation :class :initform t :initarg :slot))) > > (defmethod initialize-instance :before ((test test) &key) > (format t "Slot value: ~A~%" (slot-value test 'slot))) > > > Fresh SBCL: > CL-USER> (make-instance 'test) > Slot value: T > #<TEST {B8115E1}> > > Fresh SBCL again: > CL-USER> (make-instance 'test :slot nil) > Slot value: T > #<TEST {B92AC89}> > > So it appears that even when an initarg is provided, the slot is still > initialized to the iniform value prior to anything else.
Ecuse my ignorance, but what are you testing? During your second make-instance call the (initialize-instance :before ...) method is _not_ picking up the initform but the actual slot value from the class (remember: slot has class allocation and it's value gets initialized in the first invocation of make-instance 'test). Cheers, Ralf Mattes > -- > Resistance is futile. You will be jazzimilated. > > Scientific site: http://www.lrde.epita.fr/~didier > Music (Jazz) site: http://www.didierverna.com > > _______________________________________________ > pro mailing list > pro@common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/pro _______________________________________________ pro mailing list pro@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/pro