[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How smart are the XSLT processors? Are there any X
On 28/04/2010 00:27, Costello, Roger L. wrote:
Hi Folks, not really, it's written in a declarative language (XSLT) and is just a direct translation of a different definition.
Most (some) (saxon at least) xslt systems will do tail recursion elimination, but your first version isn't tail recursive as it calls itself twice. The second version is tail recursive. I ran both versions on Fib(100). The second version finished in less than 1 second. As for the first (declarative) version, after 10 minutes it was still executing so I killed the process.rewriting an arbitrary expression so it's tail recursive is pretty hard (impossible in general and hard to spot the cases where it's possible) No doubt someone who implemets this will say that they can rewrite some cases I conclude that, at least for the XSLT processor I used, it does not convert the first version into more efficient iterative procedures. This is sad. I would prefer writing declarative code, but if XSLT processors do not optimize the execution of declarative code then how realistic is declarative programming? You are making it pretty inefficient in any case by using value-of (or relying on your xslt engine to optimise this away) by using value-of you are asking for a document node with a text node child with string value the decimal expansion of the number, whereas if you'd used xsl;sequence it would just have returned the integer. converting between a number and a string with its decimal expansion is a surprisingly expensive operation, as is generating a document and text node, which have unique identity. Are there any XSLT processors that convert tree recursive functions into more efficient iterative procedures? yes /Roger
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|