[NTLK] NewtonScript Inheritance Question

Matej Horvat matej.horvat at guest.arnes.si
Thu Oct 13 23:19:31 PDT 2022


See "The NewtonScript Programming Language", pages 5-9 and 5-10 (119 and  
120 in the PDF).

Put another way:

1. If the variable is found in the function's lexical environment (see  
NSPL 4-10 to 4-11, 104 to 105 in the PDF - basically, parameters and  
variables declared as local), it is set there. (In this example, none of  
the variables are found there because 'SillyMethod' has no parameters and  
no locals.)

2. If the slot is found in the receiver (in this case 'one') or its _proto  
chain, it is set in the receiver. (Here, this is the case for 'a' and 'b'.)

3. If the slot is found in the recever's _parent or its _proto chain, it  
is set in the _parent. (Here, this is the case for 'c' and 'd'.)

4. If the slot is found in the receiver's _parent's _parent or its _proto  
chain, it is set in the _parent's _parent. (Here, this is the case for  
'e', 'f', and 'g'.)

And so on...

Or graphically: start at the bottom left of the "Before" illustration and  
search each level (horizontally). If you find the slot there, set it in  
the leftmost frame. Otherwise, move one level up from the leftmost frame  
and repeat.

To be honest, I think that book does a poor job of teaching NewtonScript.  
You should read NSPL and then use PNUW as a guide (if at all) until you  
understand NewtonScript and the Newton OS well enough to read Apple's  
documentation directly.


More information about the NewtonTalk mailing list