[cells-devel] make-instance, initarg, c-in

Bastian Müller turbo24prg at web.de
Tue Jun 30 21:32:02 UTC 2009


Hi,

I'm currently using cells and it works very well,
except one thing seems a little unhandy:

When defining a model it's possible to use (c-in ..)
as an initform to define a slot as a cell, but when
instantiating a class you have to supply (c-in ...)
instead the normal value, eg.

(defmodel x ()
  ((y :accessor y
      :initarg :y
      :initform (c-in nil))
   ...))

(let ((test (make-instance 'x :y (c-in 1))))
  (setf (y test) 2))

works, but instead sth like

(let ((test (make-instance 'x :y 1)))
  (setf (y test) 2))

would be nice.

I tried it with

(defmethod initialize-instance ((self x) &rest rest)
  (loop for slot in rest by #'cddr
     do (let ((value (getf rest slot))
	      (name (intern (symbol-name slot))))
	  (setf (slot-value self name)
		(c-in value)))))

but I just get:

The slot CELLS::.CELLS is unbound in the object #<X {10032D5FC1}>.
   [Condition of type UNBOUND-SLOT]

Is there any way to get this behavior?

kind regards,
  Bastian




More information about the cells-devel mailing list