The classes <type>, <class>, and <singleton>
<type> [Abstract Class]
All types (including <type> and <class>) are general instances of <type>. <type> is a subclass of <object>.
<class> [Abstract Instantiable Class]
All classes (including <class>) are general instances of <class>. <class> is a subclass of <type>. In most programs the majority of classes are created with define class. However, there is nothing to prevent programmers from creating classes by calling make, for example, if they want to create a class without storing it in a module variable, or if they want to create new classes at runtime.
If make is used to create a new class and creating the new class would violate any restrictions specified by sealing directives, then an error of type <sealed-object-error> is signaled.
The class <class> supports the following init-keywords:
- superclasses:
- Specifies the direct superclasses of the class. superclasses: should be a class or a sequence of classes. The default value is <object>. The meaning of the order of the superclasses is the same as in define class.
- slots:
- A sequence of slot specs, where each slot-spec is a sequence of keyword/value pairs.
- The following keywords and corresponding values are accepted by all implementations. Implementations may also define additional keywords and values for use within slot specs.
- getter:
- A generic function of one argument. Unless the allocation of the slot is virtual, the getter method for the slot will be added to this generic function. This option is required.
- setter:
- A generic function of two arguments. Unless the allocation of the slot is virtual, the setter method for the slot will be added to this generic function. There is no default.
- type:
- A type. Values stored in the slot are restricted to be of this type. The default value for this option is <object>.
- deferred-type:
A function of no arguments, which returns a type, and is called once to compute the type of the slot, within the call to make which constructs the first instance of that class.- init-value:
- Supplies a default initial value for the slot. This option cannot be specified along with init-function:. There is no default.
- init-function:
- A function of no arguments. This function will be called to generate an initial value for the slot when new instances are created. This option cannot be specified along with init-value:. There is no default
- init-keyword:
- A keyword. This option permits an initial value for the slot to be passed to make, as a keyword argument using this keyword. There is no default. This option cannot be specified along with required-init-keyword:.
- required-init-keyword:
- A keyword. This option is like init-keyword:, except it indicates an init-keyword that must be provided when the class is instantiated. If make is called on the class and a required init-keyword is not provided, an error is signaled. There is no default. This option cannot be specified if init-keyword:, init-value:, or init-function: is specified.
- allocation:
- One of the keywords instance:, class:, each-subclass:, constant:, or virtual:, or an implementation defined keyword. The meaning of this option is the same as adding the corresponding adjective to a define class form.
<singleton> [Instantiable Class]
The class <singleton> supports the following init-keyword:If a singleton for the specified object already exists, implementations are free to fold the two instances into one.
- object:
- The object that the singleton indicates. There is no default for this argument. If it is not supplied, an error will be signaled.
singleton object => singleton [Function]
singleton returns a singleton for object.Next section: 8. Controlling Dynamismsingleton(object) is equivalent to make(<singleton>, object: object).