'From Squeak3.6alpha of ''17 March 2003'' [latest update: #5205] on 13 May 2003 at 7:42:37 pm'! "Change Set: VeryDeepCopyUsing-tk Date: 13 May 2003 Author: Ted Kaehler Object>>veryDeepCopyUsing: is a utility method. When you have a complex data structure, involving several custom classes, veryDeepCopy on a subpart may not do what you want. When you veryDeepCopy one of your objects, it does not know which instance variable are actually pointers back to a 'global' object, which should not be duplicated. The 'parent' links in a tree are an example. These can be handled by creating veryDeepInner: and veryDeepFixupWith:. However, it may be easier to make a custom veryDeepCopy method. In it, you create a DeepCopier, and store into its references dictionary with (globalObject -> globalObject). Then you want to start a veryDeepCopy using that DeepCopier, and calling veryDeepCopyUsing: is the way to do that."! !Object methodsFor: 'copying' stamp: 'tk 5/13/2003 19:39'! veryDeepCopyUsing: copier "Do a complete tree copy using a dictionary. An object in the tree twice is only copied once. All references to the object in the copy of the tree will point to the new copy. Same as veryDeepCopy except copier (with dictionary) is supplied. ** do not delete this method, even if it has no callers **" | new refs newDep newModel | new _ self veryDeepCopyWith: copier. copier mapUniClasses. copier references associationsDo: [:assoc | assoc value veryDeepFixupWith: copier]. "Fix dependents" refs _ copier references. DependentsFields associationsDo: [:pair | pair value do: [:dep | (newDep _ refs at: dep ifAbsent: [nil]) ifNotNil: [ newModel _ refs at: pair key ifAbsent: [pair key]. newModel addDependent: newDep]]]. ^ new! !