veryDeepCopy
Tim Olson
tim at jump.net
Thu Oct 4 13:26:20 UTC 2001
Jim Benson wrote:
>I've never quite understood the myriad of copy methods copy, deepCopy,
>veryDeepCopy, veryDeepCopyWith, veryDeepCopyWithACherryOnTop, etc. Is there
>somewhere that someone has talked about this, and which to use under any
>particular set of circumstances?
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
More information about the Squeak-dev
mailing list
|