[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Comma problem Re: ANSWERS to "What's wrong with XQuery" question

Michael Kay mike at saxonica.com
Thu Jul 29 12:00:26 PDT 2010


 Comma problem Re:  ANSWERS to "What's wrong with
	XQuery"	question
 >It was somewhat surprising to me, coming from that background, that 
the precedence of "," was so low, and from the other responses, it seems 
some others shared (or at least have been made aware of) the same 
confusion, although it is, as you say, easily remedied.

The explanation of why the precedence is so low lies in the overloading 
of "," to separate arguments in a function call, which was something 
where we really had no choice. This meant that we needed the concept of 
"ExprSingle" to mean "an expression not containing a top-level comma" to 
define what was allowed as a function argument, and this decision led to 
"," having lower precedence than any other operator. I remember there 
were various suggestions for an alternative symbol for use as a 
sequence-concatenation operator, but they all looked ugly and unnatural. 
So this isn't a case of something that happened because no-one realised 
the consequences, it was a carefully-considered design decision that was 
considered less bad than the alternatives on the table.

I do remember that one of the suggestions was that comma as a 
concatenation operator should only work in conjunction with parentheses, 
so that a SeqConcatExpr would be

"(" (expr ",")* expr ")"

rather than

(expr ",")* expr

in which case constructs like "return a,b" would be errors rather than 
being mis-parsed. With hindsight that might have been a better decision, 
but it would have carried its own set of surprises; use cases where the 
expression appears within curly braces, e.g. in a function body, were 
particularly noticeable.

Michael Kay
Saxonica




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-2011 All Rights Reserved.