[cells-devel] DEF-C-OUTPUT and hello-world.lisp headscratcher

Tayssir John Gabbour tjg-lisp at pentaside.org
Sat Mar 11 13:01:12 UTC 2006


Hi all,

In cells-test/hello-world.lisp, when running DEF-C-OUTPUT, old-value
seems always bound to nil. My understanding is it should be bound to the
previous thing the slot was set to. Am I missing something?

Sourcecode and repl output below (on SBCL PPC Darwin 0.9.9):



(use-package :cells)
(use-package :utils-kt)

(defmodel computer ()
  ((happen :cell :ephemeral :initform (c-in nil) :accessor happen)
   (location :cell t
             :initform (c? (case (^happen)
                             (:leave :away)
                             (:arrive :at-home)
                             (t .cache))) ;; ie, unchanged
             :accessor location)
   (response :cell :ephemeral :initform nil :initarg :response :accessor
response)))

(flet ((fmt (name new-value old-value-boundp old-value)
         (format t "~%~A: ~15A (previously ~:[an unbound ~A~;~A~])"
                 name new-value old-value-boundp old-value)))
  (def-c-output response (self new-value old-value old-value-boundp)
    (fmt "response" new-value old-value-boundp old-value))
  (def-c-output happen (self new-value old-value old-value-boundp)
    (fmt "happen  " new-value old-value-boundp old-value))
  (def-c-output location (self new-value old-value old-value-boundp)
    (fmt "location" new-value old-value-boundp old-value)))


(defun hello-world ()
  (let ((dell
         (make-be 'computer
                  :response (c? (bwhen (h (happen self))
                                  (if (eql (^location) :at-home)
                                      (case h
                                        (:knock-knock "who's there?")
                                        (:world "hello, world."))
                                      "<silence>"))))))
    (dotimes (n 2)
      (setf (happen dell) :knock-knock))

    (setf (happen dell) :arrive)
    (setf (happen dell) :knock-knock)
    (setf (happen dell) :world)
    (values)))



;; At the repl:


CL-USER> (hello-world)

----
;;;   instancing object...
happen  : NIL             (previously an unbound NIL)
location: NIL             (previously NIL)
response: NIL             (previously NIL)
;;;   instanced object #<COMPUTER {10F59309}>
----
happen  : KNOCK-KNOCK     (previously NIL)
response: <silence>       (previously NIL)
happen  : KNOCK-KNOCK     (previously NIL)
response: <silence>       (previously NIL)
happen  : ARRIVE          (previously NIL)
location: AT-HOME         (previously NIL)
happen  : KNOCK-KNOCK     (previously NIL)
response: who's there?    (previously NIL)
happen  : WORLD           (previously NIL)
response: hello, world.   (previously NIL)



Thanks,
Tayssir



More information about the cells-devel mailing list