[resolved] access old value in cells
Posted: Sun Jan 31, 2010 8:44 am
i have a rule evaluated cell which should only change it's value in certain cases and in some it should just stay the same.
if i refer to the cell1 in it's own c? i get a dependency error of course. how can i do that, without using a old-value slot?
something else i thought of which might work is using drifters... however in my actual code cell1 is a class, so incf and decf don't work there.
Code: Select all
(in-package :cells)
(cells-reset)
(defmodel test ()
((cell1 :initarg :cell1 :accessor cell1-of)
(eph1 :cell :ephemeral :initform (c-in NIL) :accessor eph1-of)
))
(defparameter test1
(make-instance 'test
:cell1 (c? (ecase (eph1-of self)
((NIL) 0)
('POS 1)
('NEG -1)
('NOTHING (^cell1-of)))))) ; access old-value here
(setf (eph1-of test1) 'POS)
(format T "~&~S" (cell1-of test1))
(setf (eph1-of test1) 'NOTHING) ; c-dependency error
(format T "~&~S" (cell1-of test1))
(setf (eph1-of test1) 'NEG)
(format T "~&~S" (cell1-of test1))
(setf (eph1-of test1) 'NOTHING) ; c-dependency error
(format T "~&~S" (cell1-of test1))
something else i thought of which might work is using drifters... however in my actual code cell1 is a class, so incf and decf don't work there.