[Xesam] Xesam pending changes for RC2
Jaap Karssenberg
j.g.karssenberg at alumnus.utwente.nl
Thu Dec 13 15:19:55 PST 2007
Mikkel Kamstrup Erlandsen wrote:
... 8< ...
>> • What precendence do the AND and OR operators have ?
>>
>> Most programming languages give OR precedence over AND
>>
>
> Name one, I don't know any that doesn't give AND precedence :-)
>
My mistake. I was confused because parsers for script languages chop up
into OR blocks first before they evaluate the AND parts of the
statement. Reason is that you always need to eval all parts of the AND
block, while parts after an OR may not need to be evaluated. For query
languages this logic does not work the same though. Anyway this goes to
prove that there is very little difference unless you get into rather
complex statements.
>> 1 2 3 AND 4 5 6 OR 7 8 9 = (1 and 2 .. and 6) or (7 and 8 and 9)
>>
>> Giving AND precedence over OR seems less intuitive to me since AND is
>> the default operator.
>>
>
> Yes. This was discussed a while back on XDG. The conclusion was that
> boolean ops was mostly for advanced users who where likely to
> anticipate the standard precedence.
>
I see no problem giving AND precedence over OR, but I do see a problem
giving the implicit AND operator or the "+" operator precedence over OR.
So my proposal would be to make "+" the implicit operator and give AND
and OR precedence over + and - .
This makes parsing slightly more complex, but it makes queries much more
intuitive. Also this complexity allows advanced users to make fairly
complex queries without the need for grouping etc. Seems like a good
trade-off to me. Also it gives "AND" an actual purpose over the implicit
operator.
Regards,
Jaap <pardus at cpan.org>
More information about the Xesam
mailing list