To me, a bag is first and foremost a multiset.
Yes, it's a collection, but it's not *just* a collection.
It's a very specific kind of collection with a very
salient "characteristic function".
In my own Smalltalk library, #asDictionary isn't even *defined*
on things that are not dictionaries or some kind of mapping,
because let's face it, a dictionary *isn't* a collection of
Associations, and trying to make it look like one made
Smalltalk-80 rather inconsistent.�� For example, if a dictionary
were a collection of associations, you would expect
(Dictionary with: #a -> 1 with: #b -> 2) includes: #a -> 1
to be true. No, it's false.�� You would expect
(Dictionary with: #a -> 1 with: #b -> 2) asArray
to be (a->1 b->2).�� No, it's (1 2).�� In order to avoid major
confusion, I had to learn never to think of Associations in
connection with Dictionaries.�� So I expect #asDictionary to
have something to do with #keysAndValuesDo:.
or something like that.
For {1->2. 3->4} asDictionary I would have to write
Dictionary withAllAssociations: {1->2. 3->4}
except that I never actually found a use for it.
#valuesAndCounts is a method that violates good OO practice,
because it exposes (what you'd expect to be) private state.
For example,
�� b := 'abracadabra' asBag.
�� b valuesAndCounts at: $a put: 'BOOM!'.
�� b
select, Print It, BOOM!.�� It should *copy* the dictionary.