Getting and Storing Data

Data is retrieved from an object using the call:
         (slot-value object slotname)
where object is an instance object and slotname is the name of the slot whose value is desired.

Data is stored into a slot using setf:
         (setf (slot-value object slotname) value)

Since an instance is implemented as a symbol, with slot values stored on its property list, slot-value simply becomes a call to get, and set-slot-value becomes a call to setf around a call to get. A call to defsetf is provided so that setf can be used with slot-value.

It is good style to use slot-value only within methods for the class and to define messages for the external interface:

   (defmethod x ((v xyvector))
     (slot-value v 'x))

Contents    Page-10    Prev    Next    Page+10    Index