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

How much laziness is permitted?

John Snelson john.snelson at oracle.com
Thu Mar 12 10:11:38 PST 2009


  How much laziness is permitted?
Florent Georges wrote:
> John Snelson wrote:
> 
>> try { 1, 2, 3, error() } catch * { "doh!" }
> 
>> Typically, lazy evaluation will start returning items from
>> expressions one by one as they are requested. So lets say I
>> request an item from the expression above, and it gives me
>> 1. I do this a couple more times and it gives me 2 and 3.
>> Then the next time I request an item, the error() function
>> raises an error - and the implementation says "Oh -
>> wait a minute! Give me back those answers, I didn't mean
>> them - I meant to return 'doh!'.".
> 
>   Thanks.  But I still fail to see the exact problem.  If you use the whole sequence, or its 4th item, then lazy evaluation is not concerned if I am right.  And if you just use its 1st item (for instance) then an implementation is allowed to NOT report the error if it does not want to (if I am right.)

If you only need three items from the expression above, then XQuery 1.1 
says it's valid to return (1, 2, 3). However it's unusual for an XQuery 
implementation to ask an expression for 3 items - it more likely asks 
for the "next" item three times.

In this latter case, given that in general the implementation won't know 
if an error will be raised or not, the implementation is forced into 
eager evaluation of the try expression.

John

-- 
John Snelson, Oracle Corporation            http://snelson.org.uk/john
Berkeley DB XML:            http://oracle.com/database/berkeley-db/xml
XQilla:                                  http://xqilla.sourceforge.net


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