[BUG][FIX] WeakKeyDictionary>>keysAndValuesDo:

Avi Bryant avi at beta4.com
Mon Jun 14 17:33:58 UTC 2004

On Jun 14, 2004, at 6:52 AM, Boris Gaertner wrote:

> In Dolphin and VW, all collections use the  identityHash
> as an immutable hash value and that is probably a better
> solution.
> I think Collection>>hash and SequenceableCollection>>hash
> are very questionable.
> Richards examples are a strong hint that these definitions are
> not only questionable, but wrong.

There are, however, some relatively common uses cases that this would 
break, like using arrays as the keys of a Dictionary.  And would it 
mean that "#(1 2 3) = #(1 2 3) copy" but "#(1 2 3) hash ~= #(1 2 3) 
copy hash"?

I think my preferred approach would be to introduce immutable versions 
of collections (or at least of Array), that use their elements to 
calculate their #hash, but change the current #hash to be in line with 
other dialects.  Some existing Squeak code might break, but there would 
be an obvious way to fix it, and portability and semantic consistency 
would be improved in the long run.


More information about the Squeak-dev mailing list