> On 05 Apr 2015, at 12:06, Hartmut <
[hidden email]> wrote:
>
> Hi,
>
> the Dictionary>>postCopy comment reads:
> "Must copy the associations, or later store will affect both the original and the copy
You interpret the comment incorrectly: it talks about the association itself, not the value that it holds. Without Dictionary>>#postCopy associations end up being shared between the original and the copy; when you overwrite an existing entry in the original dictionary, you would also change the copy - which you do not want.
You seem to be expecting that the values that you put in should also be copied, but that is your responsibility, not that of the data structure. Think about it, this copying does not happen in arrays or ordered collections either.
Does that make sense ?
> However Association(Object)>>copy will neither copy 'key' (thats what I expect) nor 'value' (that makes the copy fail).
> I checked an older version of Squeak and VisualWorks 7 and found that also there Association misses a postCopy.
>
> My workaround for a Dictionary copy reads "... associationsDo: [ :a | a value: a value copy ] ".
>
> Does anybody know why Association does not contain this code in a postCopy method ?
>
> Thanks,
> Hartmut
>
> --
> Hartmut Krasemann
>
> Königsberger Str. 41 c
>
> D 22869 Schenefeld
>
> Tel. 040.8307097
>
> Mobil 0171.6451283
>
>
[hidden email]
>
>