[comp.sys.ti.explorer] Problem with CLOS

behrens@boulder (John Behrens) (07/02/90)

I spent the best part of a day chasing what turned out
to be the following:

(defmethod foo ((state state-class))
  (with-slots (bar) state   ;bar is a list
    (dotimes (i (length bar))
      (setf (nth i bar) <some value>))))

The behavior I got was that bar in *all* instances of state
was changed not just the instance passed into the method.

The following works:

(defmethod foo ((state state-class))
  (with-slots (bar) state   ;bar is a list
    (let ((baz
	    (make-sequence 'list (length bar) :initial-element 0)))
      (dotimes (i (length bar)(setf bar baz))
	(setf (nth i baz) <some value>)))))

I'm working in common LISP with CLOS on a MicroExplorer.
Does anyone have any idea what the problem is?

Jon

Rice@SUMEX-AIM.STANFORD.EDU (James Rice) (07/03/90)

Two ideas come to mind.

a) Bar might be a shared slot, though I suspect you will
have thought of this.

b) You might have initialized Bar with some sort of quoted
form in all instances such that the compiler puts an eq
reference to it in each bar slot.


I haven't seen any behaviour like this.



Rice.