Suppose we have defined a simple class, such as:
(defclass my-class () ( ) "Doc String")
It is now possible to create objects of that class type.
defclass has defined two new functions. One is the
constructor my-class, and the other is the predicate,
This creates and returns a new object. This object is not assigned to anything, and will be garbage collected if not saved. This object will be given the string name object-name. There can be multiple objects of the same name, but the name slot provides a handy way to keep track of your objects. slots is just all the slots you wish to preset. Any slot set as such will not get its default value, and any side effects from a slot's
:initformthat may be a function will not occur.
An example pair would appear simply as
:value 1. Of course you can do any valid Lispy thing you want with it, such as
:value (if (boundp 'special-symbol) special-symbol nil)
Example of creating an object from a class:(my-class :value 3 :reference nil)
To create an object from a class symbol, use