Fwd: [XPATH30]

In XPath 1.0 the boolean operators 'and' and 'or', behaved in common 
like the majority of high level languages, in that short-circuit rules 
applied. This is no longer the case in XPath 2.0 and the current draft 
for XPath 3.0 . In XPath 2.0/3.0 it is implementation dependent whether 
short-circuit applies or not. In my experience, I have found this 
behavior inconvenient and would have preferred short-circuit rules.

Assuming there was a good reason for disallowing short-circuit (perhaps 
providing XSLT processors improved opportunities for optimization?), I 
propose two new operators for XPath 3.0 . Both of these operators are 
binary. The operands are boolean and the expression result is boolean. I 
suggest that the proposed operands would be helpful.


op:s-and
========
   Summary
   -------
   Performs boolean logical conjuctive with a short-circuit evaluation 
rule.

   Signature
   ---------
   op:s-and($arg1 as xs:boolean, $arg2 as xs:boolean) as xs:boolean

   Rules
   -----
   The expression ...

     $a s-and $b

   ... is equivalent to ...

     if ($a) then $b else false()


op:s-or
=======
   Summary
   -------
   Performs boolean logical choice with a short-circuit evaluation rule.

   Signature
   ---------
   op:s-and($arg1 as xs:boolean, $arg2 as xs:boolean) as xs:boolean

   Rules
   -----
   The expression ...

     $a s-or $b

   ... is equivalent to ...

     if ($a) then true() else $b



Faithfully,
Sean B. Durkin

Received on Tuesday, 20 November 2012 12:55:10 UTC