Inheritance in NewtonScript
_parent
slot points to another frame from which the object inherits and is used only in these two instances:
copyCat.unknownSlot := "Grin"; someSlot := 72;Proto inheritance is used both for looking up a variable and for explicitly accessing a slot from a frame. Parent inheritance is not used when explicitly accessing a slot from a frame.
When you use slot access (like copyCat.unknownSlot
), then only copyCat
and its proto chain are searched for unknownSlot
.
On the other hand, if you do not use dot syntax (like someSlot := 72
), then lookup occurs in the following order:
someSlot
self
, and self
's proto chain.
self
's parent, and its proto chain. Continue through each ancestor of self
and each ancestor's proto chain.
someSlot
as a global variable.
copyCat:SomeMessage(felix)will search the parent chain of
copyCat
(as well as each ancestor's proto chain) to find the SomeMessage
method.
frame.slot
) differently from colon ":" lookup (frame:Method()
). Remember, ":" follows the parent and proto chains, while "." follows only the proto chain. The simplest answer to this question is "just because it does." You should simply realize that there is no grand scheme in which this distinction is a critical component, so don't think you are missing something here.
An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.
Last modified: 1 DEC 1996