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:
- 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.
- 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.
- 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.
- 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.
- 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.
- Supplies a default initial value for the slot. This option cannot be specified along with init-function:. There is no default.
- 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
- 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:.
- 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.
- 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.
- 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 Dynamism
singleton(object) is equivalent to make(<singleton>, object: object).