Next: Instance Variables Up: Creating Classes Previous: Creating Classes

## Initialization Variables

A class's initialization variables are instantiated for each object of a class. The values bound to initialization variables are

- the arguments passed to the `make-object` procedure if the object is created as a direct instance of the class; or,
- the arguments passed to a superclass initialization procedure when the object is created as an instance of a derived class.

Initialization variables can be used in the initial value expressions of instance variables. Object creation and superclass initialization are described in detail in section 6.4.

As shown in the the grammar in section 6.3, the initialization-variables part of a `class*/names` expression has one of three forms. In the first form, all initialization arguments are put into a list and variable is bound to the list. In the second form, each variable is bound to an individual initialization argument. In the last form, initialization arguments are assigned to variables preceding the dot; leftover initialization arguments are put into a list that is assigned to a the single variable after the dot.

If an initialization argument is not provided for a variable that has a default-value-expr, then the default-value-expr expression is evaluated to obtain a value for the variable. A default-value-expr is only evaluated when an argument is not provided for its variable. The environment of default-value-expr includes all of the initialization variables and all of the instance variables in the class (the latter have certainly not yet been initialized). If multiple default-value-exprs are evaluated, they are evaluated from left to right.

If too few initialization arguments are provided to `make-object` or to a superclass initialization procedure, then the `exn:application:arity` exception is raised.