MAKEINSTANCE
MAKEINSTANCE, usually written as make-instance in Common Lisp, is the standard function in the Common Lisp Object System (CLOS) used to create a new instance of a defined class. It performs the allocation of a new object and triggers the initialization machinery to set up the object's slots and state. The primary argument is the class name or class object, followed by optional keyword arguments that specify initial values for slots.
The keyword arguments to make-instance correspond to the slot names of the class (or inherited slots). For
During creation, make-instance delegates to the initialize-instance generic function. By default, a simple initialization occurs, but
In practice, make-instance forms the backbone of object creation in CLOS, enabling extensibility through the method
(defclass person ((name :initarg :name :initform "Unknown")
(age :initarg :age :initform 0)))
(make-instance 'person :name "Alice" :age 30)
See also: initialize-instance, defclass, defmethod, slot definitions.