Project

Profile

Help

Tail call optimization in Saxon.NET?

Added by Anonymous over 16 years ago

Legacy ID: #4879307 Legacy Poster: Inigo Surguy (inigo)

Hi, Is Saxon.NET 9.0.0.2 expected to perform tail-call optimization on a recursive call-template? When invoking Saxon.NET via ASP.NET inside IIS, I'm getting an IIS process crash when running a tail-recursive call-template (the same code works fine when invoked directly from VS.NET or from Oxygen). This seems most likely to be because there's a stack overflow: and for some reason, VS.NET and Oxygen have a larger stack available than the IIS process does. Ah - the other possibility is that my XSLT isn't being recognized as tail recursive. The recursive call I'm making is: <xsl:for-each select="preceding::*[1]"> <xsl:call-template name="myTemplate"/> </xsl:for-each> If Saxon doesn't recognize that the for-each can only have one value, then I imagine it wouldn't recognize it as tail-recursive. I've worked around the problem in my XSLT already; I just wanted to raise this as a possible bug/enhancement. Thank you! Inigo


Replies (4)

Please register to reply

RE: Tail call optimization in Saxon.NET? - Added by Anonymous over 16 years ago

Legacy ID: #4879607 Legacy Poster: Michael Kay (mhkay)

You are right in your analysis - an xsl:call-template instruction will not be recognized as tail-recursive if it appears within an xsl:for-each instruction. You could solve the problem by using xsl:apply-templates instead. Michael Kay http://www.saxonica.com/

RE: Tail call optimization in Saxon.NET? - Added by Anonymous over 16 years ago

Legacy ID: #4879717 Legacy Poster: Inigo Surguy (inigo)

Thank you for your quick response! Inigo

RE: Tail call optimization in Saxon.NET? - Added by Anonymous over 16 years ago

Legacy ID: #4883521 Legacy Poster: Michael Kay (mhkay)

This construct will be recognized as a tail-call in the next release. Michael Kay

RE: Tail call optimization in Saxon.NET? - Added by Anonymous over 16 years ago

Legacy ID: #4884075 Legacy Poster: Inigo Surguy (inigo)

Excellent! Thank you. Inigo

    (1-4/4)

    Please register to reply