[squeak-dev] Resume Problems
Zulq Alam
me at zulq.net
Fri Dec 19 09:51:01 UTC 2008
Hi All,
Perhaps I am misunderstanding the behaviour of
I have a class SoupTag which holds a dictionary of attributes and a
collection of children which are also soup tags.
As a shorthand for attribute access, SoupTag implements:
SoupTag>>doesNotUnderstand: aMessage
(aMessage arguments size = 0)
ifFalse: [^ super doesNotUnderstand: aMessage].
^ attributes
at: aMessage selector
ifAbsent: [super doesNotUnderstand: aMessage]
So that a SoupTag with attribute id=100 would answer 100 to #id and DNU
to any other selector. This seems to work fine but I'm having trouble
implementing a flexible find: method. The test case is
tag := SoupTag new
tag attributeAt: 'id' put: 'abc'.
tag find: [:each | (each missing = 'xyz') or: [each id = 'abc']]
And so far I have simplemented this as:
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
I expected this to effectively end up evaluating:
tag find: [:each | false or: [each id = 'abc']]
But all I get is infinite recursion from the doesNotUnderstand. I think
this should work as this little test demonstrates:
[('abc' + 1) + 1]
on: MessageNotUnderstood
do: [:e | e resume: 1] " prints 2 "
Any help is greatly appreciated.
Thanks,
Zulq.
More information about the Squeak-dev
mailing list
|