Selecting non-default ancestor initializer calls

Often, it will be appropriate (in the first section of an initializer stub procedure) to change the invocation of an ancestor's somDefaultInit initializer to some other initializer available on the same class. The rule for making this change is simple: Replace somDefaultInit with the name of the desired ancestor initializer, and add any new arguments that are required by the replacement initializer. Important: Under no circumstances can you change anything else in the first section.

This example shows how to change an ancestor-initializer call correctly. Since there is a known "Example1_withName" initializer, the following default ancestor-initializer call (produced within the stub procedure for "Example2_withName") can be changed from

Example2_Init_Example1_somDefaultInit(somSelf, ctrl);

to

Example2_Init_Example1_Example1_withName(somSelf, ev, ctrl, name)

Notice that the revised ancestor-initializer call includes arguments for an Environment and a name, as defined by the "Example1_withname" initializer.


[Back: Implementing initializers]
[Next: Using initializers when creating new objects]