Remains as defined in ANSI Common Lisp, but extra control over parsing of class options and slot options, and optimization of slot access, is provided.
The macro
defclass
is as defined in the ANSI standard with the following extensions.
For extra class options, you may need to define the way these are parsed at
defclass
macroexpansion time. See process-a-class-option for details.
For non-standard slot options, you may need to define the way these are parsed at
defclass
macroexpansion time. See process-a-slot-option for details.
By default, standard slot accessors are optimized such that they do not call slot-value-using-class. This optimization can be switched off using the
:optimize-slot-access
class option.
CL-USER 116 > (compile '(defclass foo ()
((a :type fixnum
:initarg :a
:reader foo-a))))
NIL
CL-USER 117 > (compile '(defclass bar ()
((a :type fixnum
:initarg :a
:reader bar-a))
(:optimize-slot-access nil)))
NIL
CL-USER 118 > (setf *foo*
(make-instance 'foo :a 42)
*bar* (make-instance 'bar :a 99))
#<BAR 20666FDC>
CL-USER 119 > (progn
(time (dotimes (i 1000000)
(foo-a *foo*)))
(time (dotimes (i 1000000)
(bar-a *bar*))))
Timing the evaluation of (DOTIMES (I 1000000) (FOO-A *FOO*))
user time = 1.041
system time = 0.000
Elapsed time = 0:00:01
Allocation = 2208 bytes standard / 11001760 bytes conses
0 Page faults
Timing the evaluation of (DOTIMES (I 1000000) (BAR-A *BAR*))
user time = 1.422
system time = 0.000
Elapsed time = 0:00:01
Allocation = 3456 bytes standard / 11002948 bytes conses
0 Page faults
NIL