[squeak-dev] Re: about Dictionary valuesDo:

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Tue Oct 20 01:50:03 UTC 2009


So I gave it a try with a bunch of commits
(ouch, commiting is longer than editing!)

I used #fasterKeys because the message already exist.
I cannot change keys directly, a few senders really expect a Set (plus
external packages...)

Reverting is easy, just change senders of fasterKeys -> keys, or force
load of packages from update-nice.40.mcm.

Nicolas

2009/10/19 Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>:
> 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