Attila Lendvai wrote:
After someone asked on c.l.l I spent a day on making a defparameter a Cell. The test worked but then I think I tried it live and it failed and I decided I better get back to work on Algebra (but apparently never took it out of my LPR).
while making a clet in computed-class i've also played with the idea of a cell in a defparameter, but i couldn't come up with anything without symbol-macrolet. i think that can't be done transparently with standard common lisp constructs.
I just added variables.lisp to CVS just so folks can find it, and at the same time modified cells.lpr /not/ to show it.
From there, the macro:
(defmacro def-c-variable (v-name cell &key ephemeral owning unchanged-if) (declare (ignore unchanged-if)) (let ((c 'whathef)) ;;(gensym))) `(progn (eval-when (:compile-toplevel :load-toplevel) (define-symbol-macro ,v-name (c-variable-accessor ',v-name)) (setf (md-slot-cell-type 'null ',v-name) (when ,ephemeral :ephemeral)) (when ,owning (setf (md-slot-owning 'null ',v-name) t))) (eval-when (:load-toplevel) (let ((,c ,cell)) (md-install-cell nil ',v-name ,c) (awaken-cell ,c))) ',v-name)))
So this: (def-c-variable *kenny* (c-in nil))
Expands to this: (progn (eval-when (:compile-toplevel :load-toplevel) (define-symbol-macro *kenny* (c-variable-accessor '*kenny*)) (setf (md-slot-cell-type 'null '*kenny*) (when nil :ephemeral)) (when nil (setf (md-slot-owning 'null '*kenny*) t))) (eval-when (:load-toplevel) (let ((whathef (c-in nil))) (md-install-cell nil '*kenny* whathef) (awaken-cell whathef))) '*kenny*)
Obviously still experimental. :)
ken