Declared slot types are used when
slot-valuein methods, or
(setf slot-value)in methods, or
make-instance, when slots are initialized from initforms. This currently depends on PCL being able to use its internal
make-instanceoptimization, which it usually can.
(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))
bar, and with a suitable safety setting, a type error
will occur if
value is not a
fixnum. In method
fixnum comparison can be used by the compiler.
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.