Next: Instance Variable Access Up: Classes and Objects Previous: Initial Values

# Creating Objects

The `make-object` procedure creates a new object: ``

      (make-object class init-v   )

The init-vs are passed as initialization arguments, bound to the initialization variables of class for the newly created object. If class is not a class, the `exn:application:type` exception is raised.

All instance variables in the newly created object are initially bound to the special undefined value (see section 4.1). Initialization variables with default value expressions (and no provided value) are also initialized to undefined. After values are assigned to the initialization variables, default value expressions are evaluated for un-assigned initialization variables, and then the initial value expressions and `sequence` expressions are evaluated. The expressions are evaluated sequentially from left to right, but the environment for every expression includes all of the class's variables.

Sometime during the evaluation of these expressions, superclass-declared instance variables must be initialized (once) by calling the procedure bound to super-init-variable (usually `super-init`): ``

      (super-init-variable super-init-arg   )

The super-init-args are bound to the superclass's initialization variables, following the instance variable initialization process recursively until variables from all of the ancestor classes are initialized. The initialization procedure for the `object%` class accepts zero arguments.

Instance variables inherited from a superclass will not be initialized until the superclass's initialization procedure is invoked. Note that a variable declared with `inherit` may actually have a value before the superclass's initialization procedure is invoked, because inherited variables can be overridden. However, the value of a `rename` variable is always undefined before the superclass's initialization procedure is invoked.

It is an error to reach the end of initialization for any class in the hierarchy without invoking the superclasses initialization procedure; `exn:object` exception is raised in this case. If a superclass initialization procedure is invoked more than once, the `exn:object` exception is raised.

Next: Instance Variable Access Up: Classes and Objects Previous: Initial Values