Why happen this in sbcl? Maybe a bug?
(defclass myclass ()
((s1
:initform '((a . 1) (b . 2)))
(s2
:initform '((a . 1) (b . 2)))))
(defparameter ins (make-instance 'myclass))
(setf (cdr (assoc 'a (slot-value ins 's1))) 43) ;; change only slot s1
;; here my problem
(slot-value ins 's1) ;; => ((a . 44) (b . 2)))
(slot-value ins 's2) ;; => ((a . 44) (b . 2)))
But if change :initform to :
(defclass myclass ()
((s1
:initform '((a . 1) (b . 2)))
(s2
:initform '((a . 1) (b . 3)))))
The problem disappears
I test this in sbcl 1.4.3 and 1.4.11. In clisp it seems that the problem does not arise.
(eq (slot-value ins 's1) (slot-value ins 's2))
and notice what it returns. – Curkell