Symbols and Path Expressions

Symbols


'symbolname


You specify that an identifier is a symbol by preceding it with a single quote ('). The quote suppresses the evaluation of the identifier (no variable lookup occurs). One use of symbols is as a way to provide distinct values. For instance:

x := 'red;
...
if x = 'red then
   ...
else if x = 'blue then
   ...
else if x = 'green then
   ...
To convert a string to a symbol, use the function Intern; to convert a symbol to a string, use the function SPrintObject. For instance:

Print(Intern("red"))
red

Print(SPrintObject('red))
"red"

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

Last modified: 1 DEC 1996