[squeak-dev] Resume Problems
Stéphane Rollandin
lecteur at zogotounga.net
Fri Dec 19 10:47:02 UTC 2008
hello,
> SoupTag>>doesNotUnderstand: aMessage
> (aMessage arguments size = 0)
> ifFalse: [^ super doesNotUnderstand: aMessage].
> ^ attributes
> at: aMessage selector
> ifAbsent: [super doesNotUnderstand: aMessage]
this can be simpler, since the dictionary lookup will not confuse #id
with #id:, so you can get rid of the arguments size test:
SoupTag>>doesNotUnderstand: aMessage
^ attributes
at: aMessage selector
ifAbsent: [super doesNotUnderstand: aMessage]
> SoupTag>>find: aBlock
> [(aBlock value: self) ifTrue: [^ self]]
> on: MessageNotUnderstood
> do: [:e | e resume: false].
> children do:
> [:anElement |
> | found |
> found := anElement find: aBlock.
> found ifNotNil: [^ found]].
> ^ nil
>
if there is only one element to be found, the order in which you search
for it does not matter. so you can start by scanning the children, which
makes it possible to write a simple recursive method:
SoupTag>>find: aBlock
^ children detect: [:anElement | (anElement find: aBlock) notNil]
ifNone: [
[(aBlock value: self) ifTrue: [self]]
on: MessageNotUnderstood
do: [nil]].
now I must say your overall design seems to me very complex and really
overusing the DNU mechanism. it should be possible to do what you want
in a much simpler way, but since I don't know what you want to implement
exactly I will not elaborate on this.
regards,
Stef
More information about the Squeak-dev
mailing list
|