Re: References in XPath that can be representedbyastringandstill can be garbage collected

John Snelson <[email protected]> Tue, 06 Jan 2009 10:53:48 +0000
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <[email protected]>
Vladimir Nesterovsky wrote:
> I'm not an adorer of "resource manager" nor of "modifiable reference",
> however, for the puropses of clarity can you please describle differences
> in handling:
>  a) expression depending on node identity;

In this case analysis can be done on how the result is used. If it is 
used in a manner that depends upon node identity then you must preserve 
the number of times the expression is executed - otherwise you need not.

When you need to preserve the number of times an expression is executed, 
you cannot do things like lift the expression out of a loop, memoize or 
constant fold the expression. However you can still lazily evaluate the 
expression or perform other optimisations that change the order of 
execution of the expression.

>  b) expression using xquery update (of a temporary tree);

XQuery Update is fully functional, since it is only an extension to 
return a new type of value (pending update list). Since all updates 
happen after the end of a query, the possible optimisations are not 
restricted in any way.

>  c) expression using modifiable reference?

Since the result of any sequence of modifying operations depends on the 
order of execution, any expression that performs a modification cannot 
be moved out of sequence and must be executed. Specifically, that means 
that you can't use lazy evaluation.

Some analysis may be possible to determine dependencies and allow 
expressions to be reordered - however they are complex and error prone.

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