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

Subject: RE: [xsl] RE: Is xsl:for-each "syntactic sugar"?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 7 May 2010 18:25:34 +0100
> In the book, Structure and Interpretation of Computer 
> Programs by Abelson, Sussman, and Sussman, the authors assert 
> that looping constructs (such as xsl:for-each) are syntactic sugar:

Well, they don't use that term, and you haven't defined it.

It's true that xsl:for-each is a redundant construct added to the language
for usability reasons, not to increase the computational power of the
language. If that's what you mean by syntactic sugar, so be it. On the same
token, the "+" operator is syntactic sugar, because it could have been
written as "--".

However, I think the term "syntactic sugar" has overtones that don't apply
here. There's a sense that "real programmers don't need syntactic sugar",
and also a sense that compilers are likely to strip off the syntactic sugar
and immediately rewrite the construct using the underlying primitive. But
implementations are more likely to optimize a recursive function by
compiling it into an iteration (using tail call optimization) than to
compile an iteration into a recursive function. To my mind this makes the
term "syntactic sugar" a little misleading: and I note that the passage you
cite doesn't use it.


Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

Current Thread