[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Automatic evaluation of expressions in class slots

I would like to be able to place expressions in class slots, and have them
transparently evaluated when accessed.  Is there a standard way of doing
this?  Do I need the Meta Object Protocol for this?

For example, I would like behaviour similar to the following:

(defclass foo ()
  ((slot-1 :accessor slot-1)))

(defvar x (make-instance 'foo))

(setf (slot-1 x) '(+ 2 2))

(slot-1 x)  -->  4
(slot-value x 'slot-1)  -->  4
(slot-expression x 'slot-1)  --> '(+ 2 2)



Kaveh Kardan                                       kaveh@taarna.UUCP
Systeme Taarna                                     kardank@eole.umontreal.qc.ca
Montreal Quebec Canada                             (514)844-8448