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

Re: Line break algorithm

Subject: Re: Line break algorithm
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 6 May 2020 21:37:00 -0000
Re:  Line break algorithm
> Saxon does this for templates, but I believe, not for all types of
functions. In the past I raised this problem and Dr. Michael Kay said that at
the time the XSLT WG didn't mandate recognizing and optimizing tail-recursion,
because they didn't have a definition for "tail-recursion".

Separate questions here.

Firstly, it's true that the spec says nothing about how functions are
implemented. This is a tricky area and we hit it a lot with streaming: how do
you define language behaviour that is only observable in terms of resource
usage, not in terms of functional results? The general rule is that you
shouldn't mandate anything unless you know how to write a test for it.

Secondly, the question of exactly when templates and functions are
tail-recursive in Saxon. The main differences are:

* For templates, tail-call optimization applies to mutual recursion, but for
functions, it applies only to self-recursion.

* For templates, it is permissible to sequence-concatenate the result of the
recursive call with other items returned by the template. For functions, any
operation performed on the result of the recursive call, including sequence
concatenation, means that the call is not regarded as a tail call.

* For functions, byte code generation can handle tail call optimization; for
templates, it can't.

* Type checking and conversion applied to the result of the recursive call can
mean it isn't treated as tail recursive. This depends on whether static
analysis is able to determine that type checking at run-time isn't needed.

Michael Kay
Saxonica

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.