Classes are created with the class*/names form:
local-names is:
(this-variable super-init-variable)
initialization-variables is one of:
variable
(variable variable-with-default )
(variable variable-with-default . variable)
variable-with-default is:
(variable default-value-expr)
instance-variable-clause is one of:
(sequence expr )
(public public-var-declaration )
(private private-var-declaration )
(inherit inherit-var-declaration )
(rename rename-var-declaration )
public-var-declaration is one of:
((internal-instance-variable external-instance-variable) instance-var-initial-value-expr)
(instance-variable instance-var-initial-value-expr)
(instance-variable)
instance-variable
private-var-declaration is one of:
(internal-instance-variable instance-var-initial-value-expr)
(internal-instance-variable)
internal-instance-variable
inherit-var-declaration is one of:
inherited-variable
(internal-instance-variable external-inherited-variable)
rename-var-declaration is:
(internal-instance-variable external-inherited-variable)
(class*/names local-names superclass-expr (interface-expr ) initialization-variables
instance-variable-clause
)
The class* macro is used to avoid specifying local-names:
(class* superclass-expr (interface-expr ) initialization-variables
instance-variable-clause
)
(class*/names (this super-init) superclass-expr (interface-expr ) initialization-variables
instance-variable-clause
)
The class macro omits both local-names and the
interface-exprs:
(class superclass-expr initialization-variables
instance-variable-clause
)
(class* superclass-expr () initialization-variables
instance-variable-clause
)
The this-variable and super-init-variable variables are bound in the rest of the class*/names expression, excluding superclass-expr and the interface-exprs. In instances of the new class, this-variable is bound to the object itself, and super-init-variable is bound to a procedure that must be invoked (once) to initialize instance variable bindings in the superclass (see section 6.4).
The superclass-expr expression is evalauted when the class*/names expression is evaluated. The result must be a class value or null, otherwise the exn:object:class-type exception is raised. The result of the superclass-expr expression is the new class's superclass. If null is provided as the superclass, a special ``null class'' is used as the superclass; when a class is derived from the null class, the null class portion of an object is optionally initialized from the derived class by applying super-init-variable to zero arguments.
The interface-expr expressions are also evaluated when the class*/names expression is evaluated, after superclass-expr is evaluated. The result of each interface-expr must be an interface value, otherwise the exn:object:interface-type exception is raised. The interfaces returned by the interface-exprs are all implemented by the class. For each variable in each interface, the class (or one of its ancestors) must declare a public instance variable with the same name, otherwise the exn:object:implement exception is raised.
The initialization-variables part of a class*/names expression defines the initialization variables as described in section 6.3.1. The instance-variable-clauses define the class's instance variables as described in section 6.3.2.
The result of a class*/names expression is a new class, derived from the specified superclass and implementing the specified interfaces. Instances of the class are created with the make-object procedure as described in section 6.4.