Types

Clone/DeepClone


Clone(value)
DeepClone(value)


The Clone function returns a one-level-deep copy of a reference. DeepClone, as its name implies, returns a multilevel recursive copy of a reference. When you have an immediate reference, Clone and DeepClone have the same effect--they just return their argument.

For a nonimmediate reference, Clone returns a copy of the memory block to which the reference points. DeepClone returns the same copy and recursively copies any references within that block. Thus, for arrays and frames, Clone and DeepClone operate differently as these types store references within them. FIGURE 3.4 shows the difference between Clone and DeepClone and contrasts them with standard assignment.

FIGURE 3.4 : The differences among assignment, Clone, and DeepClone.


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

Last modified: 1 DEC 1996