[squeak-dev] Splitting Set and Dictionary

Levente Uzonyi leves at elte.hu
Fri Nov 20 01:01:29 UTC 2009


On Fri, 20 Nov 2009, Igor Stasenko wrote:

> Few comments.

Thanks, they are always welcome.

> HashedCollection is hardly abstract, because it implies how to use the
> state (tally, array) in
> specific way. But i think this is fine.
>

It's abstract because it's not complete and no instrances of it should be 
created. I don't like the idea that abstract classes can't have state or 
can't have implementation details.

> A #like: method , IMO first should appear in Set, since its completely
> meaningless for Dictionary.
>

I agree. I wanted to do the split with minimal changes in behavior.

> A Set>>collect: and Set>>select: using different ways to initialize
> new collection.
> One is:
> newSet := Set new: self size.

It's an old story why Set is directly referenced here. It's the least 
wrong choice. I think a commend should be added there.

> another is:
> newCollection := self copyEmpty.

It's a nice trick to use copyEmpty here by Nicolas IIRC. It enables 
instances of Set's subclasses to properly initialize their instance 
variables (like PluggableSet or KeyedSet).

Cheers,
Levente

>
> i think they should use 'self species' .
>
> 2009/11/19 Levente Uzonyi <leves at elte.hu>:
>> Hi,
>>
>> I uploaded 3 packages to the inbox which add a common superclass to Set and
>> Dictionary. The suggested load order is:
>> 1. Collections-ul.198
>> 2. Collections-ul.199
>> 3. KernelTests-ul.110
>>
>> Loading the packages will change previous behavior in some cases:
>>
>> - Dictionary >> #copyWithout: doesn't raise an error anymore. Example:
>>  (Dictionary newFrom: { #foo -> 1. #bar -> 2 }) copyWithout: 1
>>    ==> a Dictionary(#bar->2 ) (instead of an error)
>> - No more asymmetric set-dictionary equality. Example:
>>  #(1 2) asSet = (Dictionary newFrom: { #foo -> 1. #bar -> 2 })
>>    ==> false (instead of true)
>>  (Dictionary newFrom: { #foo -> 1. #bar -> 2 }) = #(1 2) asSet
>>    ==> false (same as before)
>>
>> Cheers,
>> Levente
>>
>>
>
>
>
> -- 
> Best regards,
> Igor Stasenko AKA sig.
>
>


More information about the Squeak-dev mailing list