Symbols and Path Expressions

Path Expressions


frame.(pathExpression)


You use path expressions to refer indirectly to slots. A path expression can be any one of these three:

An example of the last type of path expression would be

[pathExpr: 'x, 'y, 'z]
It is an acceptable shortcut to separate symbols by periods (.) when the array doesn't contain any integers. Thus, the following is equivalent to the previous array:

'x.y.z 
You will use this type of indirection when you want to decide what slot to access at run time instead of compile time. Here is an example that uses this type of expression:

func()
begin
   local aFrame := {x: 1, y: 2, z: 3};
   local slotToAccess;
   if ... then
      slotToAccess := 'x;
   else if ... then
      slotToAccess := 'y;
   else
      slotToAccess := 'z;
   ...
   aFrame.(slotToAccess) := 6;
end;
Using Path Expressions for Constants

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

Last modified: 1 DEC 1996