Re: [xsl] Is xsl:for-each "syntactic sugar"?

Subject: Re: [xsl] Is xsl:for-each "syntactic sugar"?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 07 May 2010 10:00:07 +0100
On 07/05/2010 07:27, Markus Karg wrote:
1. Everything that can be done using xsl:for-each can be done using a
recursive function. (True or False)

This is not true since in reality

It's true enough for quarter to three in the morning while watching xsl-list with half an eye and the UK election results with the other half (and being asleep with the rest)



the stack size limiting the number of
recursions is much more limited than the width of your CPU limiting the
number of iterations.

How much stack size gets used up is in large part a function of the compiler, although chances are that in practice you are right and that the recursive form will use more.


> So you can do much more loops than iterations.
Also, xsl:for-each is much easier to understand than a potentially
complex recursive function (you SEE that it is a loop, while you have
NOTICE that it is recursive).
> Also, xsl:for-each can (in theory) be
implemented using parallel execution (multiple cores) while recursion
necessarily must be a single core as it is up to the coder where / when
in his particular algorithm the recursive call takes place.

the rest is more or less agreeing with the answer I gave to point 4, which you didn't quote, that despite any theoretical equivalence between the forms a real compiler is going to have an easier job with the specific construct rather than trying to spot efficient idioms using more general programming forms.



David


________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


Current Thread