[previous] [up] [next]     [contents] [index]
Next: Initial Values Up: Creating Classes Previous: Initialization Variables

Instance Variables

Each instance-variable-clause declares a number of instance variables for instances of the class, or expressions to be evaluated when an instance of the class is created. The first part of a clause is the clause specifier, one of sequence, public, private, etc. A clause specifier determines the properties of instance variables declared in its clause:

Each clause specifier can be used for any number of clauses in any order within a single class*/names expression.

Figure 6.1 summarizes the variable-declaring specifiers according to two basic properties:[footnote]

The collection of instance variable declarations induces two sets of variables:

The same identifier can be used as an internal variable and an external variable, and it is possible to use the same identifier as internal and external variables for different bindings (as long as all internal variables are distinct and all external variables are distinct).

For public and private instance variables, the instance-var-initial-value-expr expression provides a value for the variable in an object; when an initial value expression is not given, (void) is used. The process for evaluating initial value expressions is decribed in section 6.3.3 and section 6.4.

For inherit and rename instance variables, the inherited-variable or external-inherited-variable specifies a (public) instance variable from the superclass. This inheritance is verified when the class*/name expression is evaluated: if an inherited instance variable is not found in the superclass (or one of its ancestors), the exn:object:inherit exception is raised. The process that gives values to inherited variables is described in section 6.4.

figure1521
Figure 6.1: Instance variable specifier summary


[previous] [up] [next]     [contents] [index]
Next: Initial Values Up: Creating Classes Previous: Initialization Variables

PLT