
Introduction to Protos
Protos and Template Size
The template myTextButton is a frame containing four slots. Its size is based upon adding the values found in the first three slots, then adding another four bytes for the pointer to protoTextButton. Because of the way inheritance works, the template gets the benefit of protoing from protoTextButton, without having to pay a price in memory size. Thus, even though the original protoTextButton
is a much larger structure, the template remains small (see FIGURE 7.3).

FIGURE 7.3 : The relationship between a template and its proto.
Note:
In C++, an object that inherits from another object gains not only functionality, but size. In C++, a 4 byte object inheriting from a 100 byte object ends up 104 bytes big. So in NewtonScript, how big would a 4 byte object protoing from a similar 100 byte object be? The answer is 8 bytes (four belong to the original template and another four to store the _proto
pointer). The speed versus size trade-off was made in favor of size.
An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.
Last modified: 1 DEC 1996