Object Creation and Initialization (original) (raw)

ANSI Common Lisp 7 Objects

7.1 Object Creation and Initialization

The generic function make-instance creates and returns a new_instance_ of a class. The first argument is a class or the name of a class, and the remaining arguments form an initialization argument list.

The initialization of a new instance consists of several distinct steps, including the following: combining the explicitly supplied initialization arguments with default values for the unsupplied initialization arguments, checking the validity of the initialization arguments, allocating storage for the instance, filling slots with values, and executing user-supplied methods that perform additional initialization. Each step of make-instance is implemented by a_generic function_ to provide a mechanism for customizing that step. In addition, make-instance is itself a _generic function_and thus also can be customized.

The object system specifies system-supplied primary methods for each step and thus specifies a well-defined standard behavior for the entire initialization process. The standard behavior provides four simple mechanisms for controlling initialization:

7.1.1 Initialization Arguments
7.1.2 Declaring the Validity of Initialization Arguments
7.1.3 Defaulting of Initialization Arguments
7.1.4 Rules for Initialization Arguments
7.1.5 Shared-Initialize
7.1.6 Initialize-Instance
7.1.7 Definitions of Make-Instance and Initialize-Instance