Creating and Initializing Objects
Objects can be created by calling
- constructors (predefined or user defined) or
-
make
, the general constructor function or
-
allocate
, the general allocator function.
make
:
function
Arguments
- class
- The class of the object to create.
key1
obj1 ... keyn
objn -
Initialization arguments.
Result
An instance of class.
Remarks
The general constructor make
creates a
new object calling allocate
and initializes it by calling
initialize
. make
returns whatever
allocate
returns as its result.
allocate
:
function
Arguments
- class
- A structure class.
- initlist
- A list of initialization arguments.
Result
A new uninitialized direct instance of the first
argument. Remarks
The class must be a structure class,
the initlist is ignored. The behaviour of allocate
is extended at level-1 for classes not accessible at level-0. The level-0
behaviour is not affected by the level-1 extension.
initialize
:
generic-function
Generic arguments
- (object <object>)
- The
object to initialize.
- initlist
- The list of initialization arguments.
Result
The initialized object. Remarks
Initializes an
object and returns the initialized object as the result. It is called by
make
on a new uninitialized object created by calling
allocate
.
Users may extend initialize
by defining methods specializing
on newly defined classes, which are structure classes at level-0.
initialize
:
method
Specialized arguments
- (object <object>)
- The
object to initialize.
- initlist
- The list of initialization arguments.
Result
The initialized object. Remarks
This is the default
method attached to initialize
. This method performs the
following steps:
- Checks if the supplied initargs are legal and signals an error otherwise.
Legal initargs are those specified in the class definition directly or
inherited from a superclass. An initarg may be specified as a slot option
or as a class option.
- Initializes the slots of the object according to the initarg, if supplied, or
according to the most specific
initform
, if specified.
Otherwise, the slot remains unbound.
Legal initargs which do not initialize a slot are ignored by the default
initialize method. More specific methods may handle these initargs and
call the default method by calling call-next-method
.
Accessing Slots
Object components (slots) can be accessed using reader and writer functions
(accessors) only. For system defined object classes there are predefined readers
and writers. Some of the writers are accessible using the
setter
function. If there is no writer for a slot, its value
cannot be changed. When users define new classes, they can specify which
readers and writers should be accessible in a module and by which binding.
Accessor bindings are not exported automatically when a class (binding) is
exported. They can only be exported explicitly.