[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
Wed Mar 11 17:24:42 PST 2009


  How much laziness is permitted?
Michael Kay wrote:
>> Pavel Minaev wrote:
>>>   (* module 1 *)
>>>   declare function m1:gen() {
>>>       for $x in 1 to 10000 return if ($x lt 10000) then $x else error()
>>>   }
>>>
>>>   (* module 2 *)
>>>   declare function m2:trygen() {
>>>     try { m1:gen() } catch * { () }
>>>   };
>>>
>> John Snelson: As it turns out, try/catch is actually a blocking operation 
>> on lazy evaluation. 
> 
> I think that's certainly true of a naive implementation (and it's largely
> true of Saxon's current implementation). However, I think some optimization
> rewrites are still legitimate: for example, given an expression such as
> 
> (try{ E } catch * {F})[1]
> 
> I think an implementation can legitimately rewrite this as
> 
> try{ E[1] } catch * {F[1]}
> 
> exploiting the knowledge that E[1] cannot throw an error unless E throws an
> error.

Yes, that's true.

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