[xquery-talk] Fold-right

Liam R. E. Quin liam at w3.org
Thu Jan 12 05:02:54 PST 2017


On Thu, 2017-01-12 at 13:21 +0100, W.S. Hager wrote:
> Hello,
> 
> Not sure if anyone already noticed, but there's an error in the
> XPath/XQuery F&O docs, where the example implementation of array:fold
> will always return an array...
I don't believe so. Please open a bug report (see the status section of
the document for details on how to do that).

> More importantly, it seems to me that a textbook implementation of
> fold-right was used, without the notice that this will only work in a
> lazy evaluation context.

XQuery is designed so that a hybrid lazy evaluation strategy is
encouraged. Queries are rewritten extensively by many implementations.
Having said that, we don't provide e.g. infinite sequences, so it's
also possible to implement an entirely eager XQuery.

The example implementations here and there in the spec are not
necessarily efficient but they should (unless otherwise noted in the
text) be correct in all cases.

Liam


-- 
Liam R. E. Quin <liam at w3.org>
The World Wide Web Consortium (W3C)


More information about the talk mailing list