Proto Inheritance

Proto Inheritance and Inheritance Lookup

Imagine you wish to access a slot in a frame, as in this example:

Print(copyCat.sharedSlot4);
If the slot can't be found in the frame, NewtonScript then looks in the frame's proto for the slot. If the slot is still not found, then each proto in the proto chain is searched until either the slot is found, or the last proto (one without a _proto slot) is searched. FIGURE 4.3 contains a revised example with a longer proto chain. Executing this code:

Print(copyCat.faroff);
would finally find the farOff slot, but not until the entire proto chain had been searched (see FIGURE 4.3).

FIGURE 4.3 : Searching the entire proto chain to find a slot.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996