Overview of NewtonScript Inheritance
The NewtonScript inheritance model deals with objects. These objects may inherit from other objects. Here is the important factor in the relationship:
Difference inheritance is quite unlike the classic model that you would find in standard languages such as C++. Before we compare these two models in greater detail, however, let us look at an example of NewtonScript inheritance using two objects:
original
and copyCat
. FIGURE 4.1 shows the two objects (which are frames); copyCat
is inheriting from original
.
FIGURE 4.1 : One object inheriting from another.
original
, contains seven slots of its own. The second object, copyCat
, contains four slots:
uniqueSlot1
and uniqueSlot2
, are unique to copyCat
.
text
, overrides the text slot which copyCat inherits from original.
inheritanceSlot
, holds the inheritance reference.
copyCat
, which contains only four direct slots, has access to a total of ten slots (six via inheritance). One of original
's slots, text
, is not accessible, as it is overridden.
From this example, you can see that an object can inherit from another object while maintaining unique slots of its own. As in copyCat
, these unique slots can contain any of the following:
copyCat
) can respond to unique messages that the other object (original
) knows nothing about.
copyCat
).
copyCat
) has no access to the existing 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