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

Re: [XQuery] FLWOR (for-let-where-order-return) equivalent to


xquery order by
> The let clause is also redundant because references to the
> variable can be replaced by the expression to which the variable is 
> bound.

  I am not sure I agree Michael.

To be strictly formal,  LET is not syntactic sugar in XQuery.
  It is syntactic sugar in most pure functional programming languages 
(i.e. can be
eliminated by the rule that you cite) but not in XQuery, due to at least
two independent reasons:
(a) side effects as result of node constructors and
(b) context-sensitive semantics (e.g. namespaces and unordered{..})

Here are a couple of counter-examples.

(a) side effects as result of node constructors

let $x := <a/>
return fn:count(($x,$x)/.)

returns 1

while

fn:count((<a/>, <a/>)/.)


returns 2

(b) context sensitive semantics due to unordered {...}

let $x := (fn:doc("foo.xml")//a[@b=3])[1]
return unordered {  $x }

is not equivalent to

unordered {(fn:doc("foo.xml")//a[@b=3])[1]}

The first one is deterministic, the second one not.

But in reality few programmers will realize those small subtle 
differences.
Moreover, a good compiler should be able to detect the cases where
the rule you cite is applicable, and the apply it only under those 
circumstances.

Best regards,
Dana

P.S> It is late in the night and I have no XQuery processor at hand to 
run and
  check those examples  but I hope I got them right. I am sure you know 
what I
mean anyway.


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.