[squeak-dev] Re: Resume Problems
me at zulq.net
Fri Dec 19 11:55:37 UTC 2008
Stéphane Rollandin wrote:
>> 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:
> if there is only one element to be found, the order in which you search
> for it does not matter.
There could be many and order matters. This method is really findFirst,
but I'm trying to keep the names analogous to the library I'm porting.
> 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.
The goal is to be able to concisely specify complex find: queries
without having to worry about whether a tag has an attribute. This
shouldn't mean that a tag swallows messages all the time.
A tag may represent a structure like:
<p id="1">ID 1</p>
<p class="A">CLASS A
<p blah="blah" id="1">BLAH 1</p>
<p blah="blah" class="A">BLAH 2</p>
Where each p is a tag, and nested p's are children. To find the BLAH 2:
blah2 = tag find: [:each | each blah = 'blah' and: [each class = 'A']]
Each tag in the hierarchy before the desired element will throw an MNU
when an attribute is missing. This is desired, i.e.:
blah2 blah " blah"
(blah2 attributeAt: 'class') " A "
blah2 id " should signal an MNU "
Now, maybe catching the MNU is not the right way to do this but I'm not
sure how else to do it while leaving the syntax so concise.
More information about the Squeak-dev