[BUG][FIX] WeakKeyDictionary>>keysAndValuesDo:
Richard A. O'Keefe
ok at cs.otago.ac.nz
Mon Jun 14 04:58:45 UTC 2004
Someone wrote:
> Seems to be a good idea to me. First I've thought of taking "self" as
> the placeholder, but then the Set couldn't contain itself...
A Set cannot contain itself anyway. One of the fundamental things about a
Set is that you shouldn't put anything in it whose hash value will change.
Even if you add a Set to itself as the very last change, the hash value
*before* the change will be used to place it, but afterwards its hash value
will be different.
s := Set new.
s hash
=> 2589
s add: s
s hash
=> WHOOPS, INFINITE LOOP.
In fact, a *lot* of Squeak collections assume they are trees, not graphs.
a := Array new: 1.
a at: 1 put: a.
a hashy
=> WHOOPS, INFINITE LOOP.
More information about the Squeak-dev
mailing list
|