#do: on MethodDictionaries

Tim Olson tim at jumpnet.com
Mon Jan 12 04:52:31 UTC 1998


Alejandro wrote:

>MethodDictionaries activates the Dictionary>>#do: method that is 
>implemented like:
>
>do: aBlock
>    super do: [:assoc| aBlock value: assoc value ]
>
>but... assoc is a CompiledMethod (not an association) and does not 
>undestand #value
>
>Is this a bug ?

Yes, it looks like the do: protocol was missed, although associationsDo: 
and keysDo: were reimplemented for MethodDictionary.  Those are the 
obvious enumeration protocol for MethodDictionary -- it is less obvious 
that do: is useful, which is probably why it was missed.

The implementation should look something like:

do: aBlock 

	tally = 0 ifTrue: [^ self].
	1 to: self basicSize do:
		[:i | (self basicAt: i) == nil ifFalse:
			[aBlock value: (array at: i)]]




     -- tim





More information about the Squeak-dev mailing list