
Types
What Types Can Be Modified
You can modify the contents of strings, frames, arrays, and binary objects, but not the contents of symbols, real numbers, and immediates. For example, if you pass an array as a parameter to a function, when the function returns, the array could be modified:
ModifyAnArray := func(anArray)
begin
anArray[0] := 5;
end;
On the other hand, if you pass a real number as a parameter to a function, when the function returns, the real number cannot have changed. Here is the reason:
- There are operators and functions that can modify the contents of a string, frame, array, and binary object. No such operators or functions exist for symbols, real numbers, or immediates.
In Chapter 6, View System and Messages, you'll learn about one of the most common programming errors for folks new to NewtonScript--attempting to modify the contents of an object in ROM.
An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.
Last modified: 1 DEC 1996