[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
with-slots and specialized
- To: info-mcl@cambridge.apple.com
 
- Subject: with-slots and specialized
 
- From: "Andre Koehorst" <andre_koehorst@riks.nl>
 
- Date: 11 Nov 93 11:45:29 U
 
REGARDING                with-slots and specialized setf's
If  the value of a slot is set from within a call to with-slots, before and
after methods on setf are ignored. This is not the case when the call is from
within with-accessors. 
This is very counter-intuitive. But is it a bug? CLtL didn't help me very much.
Example:
(defclass test-item ()
  (
   (test-slot :initarg :test-slot :initform nil :accessor test-slot
:documentation 
   "")
  )
  (:documentation
"")
  )
(defmethod (setf test-slot) :before (to (item test-item))
  (format t "~%value of test-slot of object ~a is now ~a" item to))
(defmethod set-test-slot1 ((item test-item) value)
  (with-slots (test-slot) item
    (setf test-slot value)))
(defmethod set-test-slot2 ((item test-item) value)
  (with-accessors ((the-slot test-slot)) item
    (setf the-slot value)))
#|
(setf (test-slot (make-instance 'test-item)) 10)
(set-test-slot1 (make-instance 'test-item) 10)
(set-test-slot2 (make-instance 'test-item) 10)
|#
Any ideas? Thanks,
Andre Koehorst
email: andre@riks.nl
Research Institute for Knowledge Based Systems
Maastricht, The Netherlands.