If you run this in 1.1:

| dict |
dict := WeakKeyDictionary new.
dict at: 'foo' copy put: 'bar'.
Smalltalk garbageCollect.
dict associationsDo: [:assoc | self halt].
dict do: [:val | self halt]


It stops in the second halt, but not the first.

This is because #associationsDo: does not include associations whose
keys have been GCed, but #do: *does* include values whose corresponding
keys have been GCed.

This behavior seems inconsistent, and not particularly useful, and also
seems to contradict the comments by the author in the Squeak bug from
2007, from which I'd think that #do: would not include the value which
it currently does.

So I *think* this is an oversight, and is easy to fix by defining
WeakKeyDictionary>>do: in terms of self associationsDo:.

But then there's the question of #size. The collection above answers 1
to #size, which also seems wrong.


Comments?

Regards,

-Martin

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to