xsl-list
[Top] [All Lists]

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

2010-05-07 12:25:57

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 


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--