[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: tail recursion optimization (was How efficient is

Subject: Re: tail recursion optimization (was How efficient is DVC?)
From: "David Rosenborg" <darolst@xxxxxxxxxx>
Date: Sun, 23 Mar 2003 11:44:44 +0100
tail recursion optimization
Mike Brown wrote:

>   <xsl:template match="group">
>     <xsl:copy>
>       <xsl:copy-of select="@*"/>
>       <xsl:copy-of select="./city"/>
>     </xsl:copy>
>     <xsl:apply-templates select="./group"/>
>   </xsl:template>
>
> I don't know if any processors can optimize this. It may seem obvious to
you
> and me that the apply-templates instruction will result in this same
template
> being applied, but there might be some other template that also matches
> certain 'group' elements at a higher priority, so there's no easy way for
the
> processor to be sure (before runtime) that this template will be the one
that
> is invoked for every one of the selected nodes. Or at least, the analysis
> required to be certain that this is tail-recursive is not simple enough
that
> anyone has bothered to figure it out yet. (Suggestions welcome...)
>

>From a tail call perspecitve, there is no real difference between a named
template call and applying templates. Tail call opt. has more to do
with where the call appears than how and what is being called.
The key issue is to leave or reuse the current stack frame before you
make the call. The only difference in an apply-templates call is that
it actually issues one call per selected node, so you would need to reuse
the
stack frame for each of these calls. The fact that the actual template
applied
is decided dynamically is not a tail call issue.

Cheers,
David

-----------------------------------------------
David Rosenborg
Pantor Engineering AB


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

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.