Combining Proto and Parent Inheritance

Don't Use _parent

It will seem natural to write code which accesses the _parent pointer much as you could directly use the _proto pointer. But it does not work as you intend. Instead, you'll usually use :Parent(), a view message that returns the parent view. If you happen to be writing methods for nonview objects, you can use self._parent.

For example, instead of:

Print("my parent is" && _parent);
use:

Print("my parent is" && :Parent());

Note:You cannot use _parent because of a quirk in the current NewtonScript runtime implementation. The runtime interpreter itself uses inheritance. As your method is executing, _parent and self both point to the frame that received the message. Only when you use self._parent will you retrieve the _parent slot from the correct frame.


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

Last modified: 1 DEC 1996