Dictionaries broken in 3.9a

Chris Muller chris at funkyobjects.org
Tue Sep 20 05:40:34 UTC 2005


Sorry if my "fix" disrupted you Andreas, I guess I fixed the wrong thing.  
But while Dictionary's appear able to contain nil keys afterall, what about
WeakKeyDictionarys?  As their keys are garbage-collected and converted to nil
it would be unpredictable, at best.

Therefore, what do you think of my overriding #associationsDo: in
WeakKeyDictionary, which was the real crux of my original fix back in June of
'04?  I should have just stopped with this..

associationsDo: aBlock 
	"Evaluate aBlock for each of the receiver's elements (key/value 	
	associations)."

	super associationsDo:
		[ : eachAssoc |  | eachKey |
		eachKey _ eachAssoc key.  "reference to ensure no GC"
		eachKey ifNotNil: [ aBlock value: eachAssoc ] ]

I've run with this since that time without any problem, but even better with
expert feedback.

Incidentally, there may be a few special side-effects to having a nil key in a
regular Dictionary which could bite at some point.  For example:

  (Dictionary new at: nil put: 'nil') keys

Regards,
 Chris




More information about the Squeak-dev mailing list