[squeak-dev] Re: about Dictionary valuesDo:

Igor Stasenko siguctua at gmail.com
Wed Oct 21 01:58:00 UTC 2009


I wonder, if its a feasible to make a proxies which instead of
creating a separate collection
will direct the requests to dictionary, i.e.:

Set subclass: #DictionaryKeys
instanceVariableNames: 'dict'
...

then:

Dictionary>>keys
  ^ DictionaryKeys on: self


same for values.
Any #asXXX methods should instantiate new collection. But any
iterations, like #do: etc.. should use dictionary.


2009/10/21 Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>:
> 2009/10/20 Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>:
>> So my plan is currently:
>>
>> - track #keys usage, and use #asSet where due to be future proof
>> - this involves inquiring some keys senders like selectors and classVarNames
>
> done, I added very few asSet
> and I changed classVarNames messages to return a sorted Array. Hope it
> works OK (no add: no remove: ).
> Note that sorted Array do compare well with equality =
>
>> - publish a mcm
>
> update-nice.40.mcm
>
>> - change keys to behave like fasterKeys
>> - publish a mcm
>
> Done, but the server just lost update-nice.41.mcm ...
>
>> - revert fasterKeys senders to just send keys (except the bug I found,
>> and a few #sort shortcuts)
> Note: I kept (x keys asArray sort) rather than just (x keys sort) just
> for compatibility issues.
>
> - publish a mcm
>
> update-nice.42.mcm but now that update-nice.41.mcm disappeared, I
> don't know if it will work OK
>
> - deprecate #fasterKeys
>
> Done with my contract
>
> Now we just have to chase the eventual bugs...
>
> Nicolas
>
>
>>
>> Don't know if feasible in one evening...
>>
>> 2009/10/20 Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>:
>>> well, among 49 senders of keys, I see very few problem:
>>>
>>> Bag>>#asSet obviously
>>> Behavior>>#selector the comment tells Set, but is it necessary ?
>>>
>>> among 92 usages of selectors
>>>
>>> basicLocalSelectors: aSetOrNil
>>>        localSelectors := aSetOrNil
>>> traits ? didn't try to follow further
>>>
>>> some will use remove which is not an Array protocol (removeAllFoundIn:
>>> from #replaceSilently:to:)
>>>
>>> some usages like class selectors includes: will be a bit less efficient
>>>
>>> #classVarNames comment tells a Set, though code would behave as well
>>> with a sorted collection...
>>>
>>> some = test might not work if collection is arbitrarily ordered
>>> (tempRefs keys = method startpcsToBlockExtents values asSet)
>>>
>>> ImageSegment findRogueRootsRefStrm: will use remove:
>>>
>>> A few asSet should be necessary.
>>>
>>> Nicolas
>>>
>>>
>>> 2009/10/20 Andreas Raab <andreas.raab at gmx.de>:
>>>> Nicolas Cellier wrote:
>>>>>>
>>>>>> Can you provide some examples of places that break?
>>>>>
>>>>> Look among 49 remaining senders of keys, a few use usage like #selectors
>>>>> do.
>>>>
>>>> Looking through this, nothing springs to mind that would break. Even places
>>>> like, e.g., aClass selectors includes: aSelector should continue to work
>>>> with the one possible exception that in cases where IdentityDictionary keys
>>>> are used the resulting collection should compare identity not equality,
>>>> which would be a problem if there were code that expects e.g., Object
>>>> selectors includes: 'yourself' => false. (that seems rare)
>>>>
>>>> But other than that I don't really see anything that would break with the
>>>> change. Have you tried making the change and just run all the tests to see
>>>> which ones break and why?
>>>>
>>>> Cheers,
>>>>  - Andreas
>>>>
>>>>
>>>
>>
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list