Common Lisp the Language, 2nd Edition
The generic function make-instance behaves as if it were defined as follows, except that certain optimizations are permitted:
(defmethod make-instance ((class standard-class) &rest initargs) (setq initargs (default-initargs class initargs)) ... (let ((instance (apply #'allocate-instance class initargs))) (apply #'initialize-instance instance initargs) instance))
(defmethod make-instance ((class-name symbol) &rest initargs) (apply #'make-instance (find-class class-name) initargs))
The elided code in the definition of make-instance checks the supplied initialization arguments to determine whether an initialization argument was supplied that neither filled a slot nor supplied an argument to an applicable method. This check could be implemented using the generic functions class-prototype, compute-applicable-methods, function-keywords, and class-slot-initargs. See the third part of the Common Lisp Object System specification for a description of this initialization argument check. [The third part has not yet been approved by X3J13 for inclusion in the forthcoming Common Lisp standard and is not included in this book.-GLS]
The generic function initialize-instance behaves as if it were defined as follows, except that certain optimizations are permitted:
(defmethod initialize-instance ((instance standard-object) &rest initargs) (apply #'shared-initialize instance t initargs)))
These procedures can be customized at either the Programmer Interface level, the meta-object level, or both.
Customizing at the Programmer Interface level includes using the :initform, :initarg, and :default-initargs options to defclass, as well as defining methods for make-instance and initialize-instance. It is also possible to define methods for shared-initialize, which would be invoked by the generic functions reinitialize-instance, update-instance-for-redefined-class, update-instance-for-different-class, and initialize-instance. The meta-object level supports additional customization by allowing methods to be defined on make-instance, default-initargs, and allocate-instance. Parts 2 and 3 of the Common Lisp Object System specification document each of these generic functions and the system-supplied primary methods. [The third part has not yet been approved by X3J13 for inclusion in the forthcoming Common Lisp standard and is not included in this book.-GLS]
Implementations are permitted to make certain optimizations to initialize-instance and shared-initialize. The description of shared-initialize in section 28.2 mentions the possible optimizations.
Because of optimization, the check for valid initialization arguments
might not be implemented using the generic functions
function-keywords, and class-slot-initargs. In addition,
methods for the generic function default-initargs and the
system-supplied primary methods for allocate-instance,
and shared-initialize might not be called on
every call to make-instance or might not receive exactly the
arguments that would be expected.