Should Dictionary associations be shared?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Should Dictionary associations be shared?

Chris Muller-4
This following assertion fails.

|d1 d2 | d1:=Dictionary new.  d2:=Dictionary new.
d1 at: 'one' put: 1.   d2 at: 'two' put: 2.
d1 addAll: d2.
d2 at: 'two' put: nil.
self assert: (d1 at: 'two')=2

To me it seems like Associations should not be shared between
Dictionary's.  Thoughts?

Reply | Threaded
Open this post in threaded view
|

Re: Should Dictionary associations be shared?

Frank Shearar-3
On 22 December 2012 19:53, Chris Muller <[hidden email]> wrote:

> This following assertion fails.
>
> |d1 d2 | d1:=Dictionary new.  d2:=Dictionary new.
> d1 at: 'one' put: 1.   d2 at: 'two' put: 2.
> d1 addAll: d2.
> d2 at: 'two' put: nil.
> self assert: (d1 at: 'two')=2
>
> To me it seems like Associations should not be shared between
> Dictionary's.  Thoughts?

Associations should not be shared between Dictionaries. That kind of
sharing works well with immutable data structures, but Dictionary is
mutable. Thus, the sharing can cause things distant in space and time
to influence each other's behaviour, which would make for an
unpleasant debugging session.

frank