I'm trying to learn Cells by poking at the examples to see if I can predict the result. I'm using the April 05 snapshot of CMUCL with Ray's patches to Require for ASDF. Cells-test passes without any obvious glaring errors, but most of it is greek to me.
In boiler-example.lisp, I can run (boiler-1) without a problem. I was trying to understand what cv-assert did, so I added a line to induce an error:
(defmodel boiler1 () ((id :cell nil :initarg :id :accessor id :initform (random 1000000)) (status :initarg :status :accessor status :initform nil) ;; vanilla cell (temp :initarg :temp :accessor temp :initform nil) (vent :initarg :vent :accessor vent :initform nil) ))
(defun boiler-1 ()
;; resets debugging/testing specials (cell-reset)
(let ((b (make-instance 'boiler1 :status (c? (if (< (temp self) 100) :on :off)) :temp (c-in 20) :vent (c? (ecase (^status) ;; expands to (status self) and also makes coding synapses convenient (:on :open) (:off :closed))))))
(cv-assert (eql 10 (temp b))) ; ADDED TO TRIGGER the Hyperspecs "correctable error" (cv-assert (eql 20 (temp b))) (cv-assert (eql :on (status b))) (cv-assert (eql :open (vent b)))
(setf (temp b) 100) ;; triggers the recalculation of status and then of vent
(cv-assert (eql 100 (temp b))) (cv-assert (eql :off (status b))) (cv-assert (eql :closed (vent b))) ))
It was my reading of the Hyperspec's entry for assert, which lives inside cv-assert that I would get a correctable error and be able to alter the 10 to 20, and have the test pass. But I get:
CELLS> (boiler-1)
Error in function LISP::ASSERT-ERROR: (EQL 10 (TEMP B)) ...failed [Condition of type SIMPLE-ERROR]
Restarts: 0: [CONTINUE] Retry assertion. 1: [ABORT ] Return to Top-Level.
Debug (type H for help)
(LISP::ASSERT-ERROR (EQL 10 (TEMP B)) NIL "~&~a~&...failed" (EQL 10 (TEMP B))) Source: ; File: target:code/macros.lisp (RESTART-CASE (ERROR COND) (CONTINUE () :REPORT (LAMBDA # #) NIL)) 0] H
The prompt is right square brackets, the number indicating how many recursive command loops you are in. Debug commands do not affect * and friends, but evaluation in the debug loop do affect these variables. Any command may be uniquely abbreviated.
Getting in and out of DEBUG: Q throws to top level. GO calls CONTINUE which tries to proceed with the restart 'continue. RESTART invokes restart numbered as shown (prompt if not given). ERROR prints the error condition and restart cases. FLUSH toggles *flush-debug-errors*, which is initially t.
The name of any restart, or its number, is a valid command, and is the same as using RESTART to invoke that restart.
Changing frames: U up frame D down frame T top frame B bottom frame
[RETURN FOR MORE, Q TO QUIT HELP TEXT]: q
0] GO
Error in function LISP::ASSERT-ERROR: (EQL 10 (TEMP B)) ...failed [Condition of type SIMPLE-ERROR]
Restarts: 0: [CONTINUE] Retry assertion. 1: [ABORT ] Return to Top-Level.
Debug (type H for help)
(LISP::ASSERT-ERROR (EQL 10 (TEMP B)) NIL "~&~a~&...failed" (EQL 10 (TEMP B))) Source: (RESTART-CASE (ERROR COND) (CONTINUE () :REPORT (LAMBDA # #) NIL)) 0]
------------------------------------------------------------------
So, do I have the right idea that a user opportunity to correct an error exists? Might this be related to a CMUCL bug afterall? Is the example boiler-1 too simple to support this testing?
TIA
Ron