GsDevKit / glassdb

Automatically exported from code.google.com/p/glassdb
0 stars 0 forks source link

Squeak-style deepCopy semantics #79

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
~From Igor: 

Since we started about compatibility, i have some things to report, 
which i had to deal during porting. 

deepCopy 
- in Squeak , it behaves like a simple copy, which recursively 
visiting references and sending to them #deepCopy. However, there is 
no identity dictionary to check duplicated references, for this means 
there is a 

veryDeepCopy. 
A veryDeepCopy in Squeak behaves similar to deepCopy in G/S. The 
difference is, that there are some useful extensions, like 
#veryDeepInner: and #veryDeepFixup: which can be overridden by 
subclasses to customize deep copy behavior. 

shallowCopy. 
This is the last thing i had troubles with. In G/S it simply calls #copy. 
In Squeak, there are expectation, that #shallowCopy is a low-level 
copy message and you don't need to customize it, while #copy - can and 
should be , if needed. And this was a source of problems: some classes 
having a customized #copy , which shouldn't be called during 
#shallowCopy. 

I think, Squeak's #shallowCopy usage/implementation is more correct 
than in G/S. I propose you to review its implementation. 

There's another copy message - #clone, but we don't using it. The 
difference between shallowCopy, that clone tries to inherit as much as 
possible properties from original (read: identity hash).

Original issue reported on code.google.com by henrichs...@gmail.com on 24 Mar 2010 at 7:57