On Wed, 13 Jan 2010, Lukas Renggli wrote:
It would be cool to merge #clone and #shallowCopy, and all the different #deepCopy* instances. Also the implementation of #deepCopy might need some cleanup, it seems to be rather complicated for such a trivial task of copying a object graph.
The implementation of #deepCopy seems to be pretty straightforward. I wonder how it could be simpler.
It doesn't handle recursion, which makes it pretty useless.
That's what #veryDeepCopy does, though it does it in a more complicated way. #deepCopy has the advantage of being simple and fast. Levente
I would suggest something like:
deepCopy ^ self deepCopy: IdentityDictionary new
deepCopy: anIdentityDictionary | copy | anIdentityDictionary at: self ifPresent: [ :value | ^ value ]. copy := anIdentityDictionary at: self put: self shallowCopy preDeepCopy. " copy all the variables of copy using 'var deepCopy: anIdentityDictionary' " ^ copy postDeepCopy
-- Lukas Renggli http://www.lukas-renggli.ch
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project