Next: , Previous: , Up: CLOS   [Contents][Index]


2.23.2 Slot Type Checking

Declared slot types are used when

Example:

(defclass foo ()
  ((a :type fixnum)))

(defmethod bar ((object foo) value)
  (with-slots (a) object
    (setf a value)))

(defmethod baz ((object foo))
  (< (slot-value object 'a) 10))

In method bar, and with a suitable safety setting, a type error will occur if value is not a fixnum. In method baz, a fixnum comparison can be used by the compiler.

Variable: pcl::*use-slot-types-p*

Slot type checking can be turned off by setting this variable to nil, which can be useful for compiling code containing incorrect slot type declarations.