[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Is the semantics of the "or" operator implementat

Subject: Re: Is the semantics of the "or" operator implementation-dependent?
From: "Abel Braaksma (Exselt) abel@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 Sep 2014 15:53:12 -0000
Re:  Is the semantics of the "or" operator  implementat
>> No, the semantics not, the order of execution is, however, which means that
in error-cases, you can have different outcomes between processors. This is
not different from other languages, in C#, F#, Java, C++ similar forms of
optimization exist.

> Considering B'15.7 in the Java Language Specification: Do you have an actual
example/experience of some Java expression (logical "or") where different
outcomes between processors have been observed?

Note that I said "similar forms". I checked, and I think that all mentioned
languages do left-to-right short-circuitring only (didn't know, but apparently
this is also known as  McCarthy evaluation), which allows code like this,
which is deterministic:

if(a != 0 && b / a > 1) { return "larger than one division;" }
if(ptr && ptr->fileExists()) { return "file exists"; }

But, a better comparison would be with SQL, which does the same as XPath. In
fact, a user summarizes the order of evaluation for SQL in boolean expressions
as

"It does when it feels like it, but not in the way you immediately think of."

See:
http://dba.stackexchange.com/questions/5333/logical-operators-or-and-in-condi
tion-and-order-of-conditions-in-where, where the user also explains the main
reason (which Michael Kay already mentioned):

"We as developers have to be aware that SQL Server works differently. It is a
cost based system. To get the optimal execution plan for our query the query
processor has to evaluate every where condition and assign it a cost. "

Which can just as well be recast with XPath (or XQuery and XSLT by extension,
where order of evaluation is undefined, not only for boolean expressions):

"We as developers have to be aware that XPath works differently. It is a cost
based system. To get the optimal execution plan for our XPath query the
processor has to evaluate the conditions everywhere and assign it a cost. "

Cheers,

Abel Braaksma
Exselt XSLT 3.0 streaming processor
http://exselt.net

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.