Re: [xsl] Re: questions about XSLT philosophy: how much is too much?

Subject: Re: [xsl] Re: questions about XSLT philosophy: how much is too much?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 21 Mar 2003 19:09:01 GMT
> for someone not used to it and coming in with
> the understanding that XSLT was being promoted as a *functional*
> language, seeing it being used in what appears to be a non-functional
> (i.e., procedural) way would *seem* not natural.  that's all
> 


The term "functional" applies to the language rather than to any
particular program written in the language.
In fact unlike say some lisps or standad ML, XSLT is a rather pure
declarative language with essentially no imperative instructions.

You can fill your lisp with imperative setq statements if you wish, but
in XSLT it's just not possible to write procedural code.
In particular xsl:for-each and xsl:template both fall
very naturally in the functional paradigm, they just happen to use XML
syntax rather than f(x) syntax.
> 
> and yet, in the very next paragraph, he writes, "Instead of 
> looping, XSLT uses iteration and recursion."  excuse me but,
> where i grew up, iteration is just another word for looping.
> and looping sure seems to have a procedural programming history.

In any loop construct something needs to change otherwise you'll loop
for ever. In a C for loop or fortran DO loop etc what gets changed is
the value of some variable so the whole construct requires the
imperative/procedural notion of a variable whose value may be
changed. Loops in functional languages are different, you just
iterate some function over all the elements in some structure, and you
end when you've done them all. Just as the previous kind of loop is
syntactic shorthand for an assignment, an if test and a goto, this
kind of loop is shorthand for recursing over the structure of the
object, It is perfectly natural in a functional language.

David

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


Current Thread