This is interesting that you present that as a Bag. I'm too sick now  
(my brain
is wandering across my room) to really reply something clever.

I thought that a bag was more an counting elements container

> a) multiple values can be in the dictionary:
>       (Dictionary new) at: 'one' put: 1; at: 'first' put: 1; yourself.

For me to be bag would mean more

> dc := (DictionaryBag new) at: 'one' put: 1; at: 'one' put: 2;  
> yourself.
   dc at: one
        -> #(1 2)

Stef    

>>>
>> From the st80 origin, Dictionary is a Bag of values.
> Each value is indexed with a unique key.
>
> It is a Bag because:
> a) multiple values can be in the dictionary:
>       (Dictionary new) at: 'one' put: 1; at: 'first' put: 1; yourself.
> b) values are unordered:
>       | d1 d2 |
>       (d1 := Dictionary new: 3) at: 'one' put: 1; at: 'two' put: 2.
>       (d2 := Dictionary new: 4) at: 'one' put: 1; at: 'two' put: 2.
>       stream := (String new: 64) writeStream.
>       d1 do: [:v | stream print: v; cr].
>       d2 do: [:v | stream print: v; cr].
>       stream contents.
> And as you can see, #do: does apply on values, as would #collect:  
> #select:
> #reject: #includes: etc...
>
> The fact that Dictionary is implemented with Associations could be  
> seen as a
> private implementation defined feature.
> Though, by tradition, associationsDo: has been made a public  
> interface, so as
> the possibility to directly add an Association.
>
> But semantically, Dictionary is not a Set of Associations.
> Example:
>       (Set new) add: $a->65; add: $a->1; yourself.
>       (Dictionary new) add: $a->65; add: $a->1; yourself.
>
> Dictionary could be viewed as a Set of keys.
>> From that POV, it shared enough property with Set to be implemented  
>> as a
> subclass. That's all.
> I proposed once to detach Set and Dictionary from a common ancestor  
> just for
> clarity...
>
> Nicolas
>
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>


_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to