Subject: veryDeepCopy
From: Tim Olson <tim@jump.net>
To: <squeak-dev@lists.squeakfoundation.org>
Date: Thu, 4 Oct 2001
Here's something I posted to comp.lang.lisp about Squeak's copying methods when this discussion came up there:
The Object class provides a number of default copy operations:
clone
make a copy of the object which shares instance variables (shallow)
shallowCopy
"public interface" to clone, used to override for things like singletons
copy
defaults to shallowCopy, general copying method overriden by subclasses as required
copyTwoLevel
copy of object with shallow copy of instance variables
deepCopy
(recursive) copy of object with deepCopy of all instance variables
veryDeepCopy
(probably should really be named "structureCopy" or something) copies the object, using a dictionary to keep track of the mapping from old objects to new objects, so that various identities are preserved.
It is up to the various subclasses to override any of these as required, or implement a new copying interface.
– tim
If you want to copy some instance variables deeply and others not, see the discussion in the class comment of DeepCopier for further guidance. – Ross Boylan; RossBoylan@stanfordalumni.org