- From: Tim Mills <tim@cbcl.co.uk>
- Date: Tue, 10 Dec 2013 09:51:56 +0000
- To: Christian Grün <christian.gruen@gmail.com>
- CC: Michael Kay <mike@saxonica.com>, Florent Georges <fgeorges@fgeorges.org>, EXPath CG <public-expath@w3.org>
- Message-ID: <52A6E43C.9050807@cbcl.co.uk>
On 09/12/2013 21:42, Christian Grün wrote: >>>> let $a := file:append-text('foo.txt', ' cat') >>>> let $b := file:append-text('foo.txt', 'fish') >> I'm not sure what you mean by function order - and I think that's my point. XQuery doesn't define an order of evaluation. > Pardon my broken English. By function order, I meant to say that ' > cat' must be appended to the file 'foo.txt' before 'fish'. I didn't mean to suggest it was your English (which is superb), I was just making the point that function order isn't something that has been defined. When reading a program, the programmer is conditioned to perceive an order based on the usual left-to-right, top-to-bottom order of languages such as C (or even ML), but anyone who's looked at the execution plan that comes out of an XQuery processor knows that the order may not be preserved. > > I guess we are talking about a similar thing: On the one hand, the > current version of XQuery provides no means to enforce evaluation > order. On the other hand, varioous XQuery processors are available > that provide an implementation of the File Module, or other > side-effecting modules, and that assume that code (may it be > ·nondeterministic· or ·side-effecting·) is evaluated in the order in > which it's specified in the query (as part of a FLWOR expression, as > multiple expressions separated by commas, or any other way). How can > we resolve this discrepancy? The stalled XQuery Scripting Extensions proposed an order of evaluation, so that's one approach; the monadic approach of Haskell is my personal favourite; then there's the "programmer beware" approach of hoping that the processor doesn't reorder expressions. The foolhardy programmer might write |<xsl:attribute *name* = "{ (file:append( ...), 'foo') }" namespace? = "{ (file:append ( ...), 'urn:something') } select? = "{ (file:append (...), 'red') }" on-empty? = "{ (file:append (...), 'empty') }" />| Either it has to be clear that all bets are off, or an order of evaluation has to be defined. Cheers, Tim
Received on Tuesday, 10 December 2013 09:43:19 UTC