Re: Variables and constants
This is more of a philosophical question. Since I haven't worked with functional programming languages before, can anyone explain to me the rationale for not having true variables a'la procedural programming languages (i.e. you can re-assign the value of an existing variable)?
Yes, it is rather a philosophical question. There was much debate about it here on the list when the first Working Draft of the spec to mention it first appeared.
David Carlisle just mentioned, in a reply to another message, XSLT's "side-effect-free" nature, and it applies here too. The "instructions" in an XSLT stylesheet are not true procedural instructions, in the manner of those found in procedural languages, but simple *declarations* of an effect to be achieved in the result tree given some condition in the source. This means that an XSLT processor doesn't need to process the instructions in any particular order -- again, very different from procedural languages. And if the instructions aren't processed in any particular order then the notion of a variable whose value may from time to time be reassigned becomes practically useless. In a procedural language, a variable's value can be relied on only at the point of reference -- which of course changes if you change the order of execution.
In general, I agree that developers accustomed to procedural-language conventions need to make a conceptual leap to use XSLT effectively. (And the term "variable" is only the tip of the iceberg.) But this list is peopled with dozens of such developers who've made the leap and been delighted with what they've learned.
(All just my opinion, of course.)
================================================================ John E. Simpson | I'm having amnesia and deja vu at the http://www.flixml.org | same time. I think I've forgotten simpson@xxxxxxxxxxx | this before. (Steven Wright)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
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