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



If an attempt is made to access a slot in an instance of a standard
class, and the name of the slot provided is not a name of a slot in that
class, then the generic function slot-missing is invoked.  

slot-missing class instance slot-name operation
                 &optional new-value                     

The required arguments to slot-missing are the class of the instance
being accessed, the instance, the slot-name, a symbol that indicates the
operation which caused the trap to slot-missing.  The optional argument
to slot-missing is used when the operation is attempting to set the
value of the slot.

The generic function slot-missing is not intended to be called by
programmers.  Programmers are expected to write methods for it.
The generic function slot-missing is called by
  (setf slot-value-using-class)
For each of these operations the corresponding symbol for the operation
argument is

The default method on slot-missing signals an error.

This set of arguments (including the class of the instance) facilitates
defining methods on the metaclass for handling slot-missing.  For
example, this enables an easy implementation of dynamic slots; that is:

(defmethod slot-missing ((class dynamic-class) obj slot operation
                         &optional nv)
  (ecase operation
      (slot-value (get-dynamic-slot obj slot))
      (setf (set-dynamic-slot obj slot nv)
      (slot-boundp (exists-dynamic-slot-p obj slot))))