[squeak-dev] Re: about Dictionary valuesDo:
Nicolas Cellier
nicolas.cellier.aka.nice at gmail.com
Mon Oct 19 21:40:23 UTC 2009
Traditionally in st80, #keys returns a Set of keys, and #values a Bag
of values...
Rationale: none of them is ordered.
Now I noticed squeak #values returns an Array, and wondered why by
analyzing senders.
Most of them are superfluous, and maybe this will explain latest wave
of commits in the trunk.
Now I find the idea of answering an Array a good one,
- because it is faster than a Bag (no lookup)
- for historical reasons, some senders expect a SequenceableCollection,
- while no senders seems to rely on a Bag protocol
Others think the same should apply to keys, because of speed too, and
because of rare expectation of Set specific protocol.
This is #fasterKeys.
What do squeakers think ? Shouldn't we do to the #keys what we did to
the #values ?
Nicolas
2009/10/19 Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>:
> Is there any difference with #do: ?
> If not, I suggest deprecating #valuesDo:
>
> More other, browsing #values senders, this pattern:
> aDictionary values do: [:aValue | self doSomethingWith: aValue].
> can often be replaced with:
> aDictionary do: [:aValue | self doSomethingWith: aValue].
> except of course when aDictionary is modified inside the loop.
>
> Nicolas
>
More information about the Squeak-dev
mailing list
|