|
[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" questionMichael Kay mike at saxonica.comThu Jul 29 12:00:26 PDT 2010
>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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






