RE: [XSLT 2.0]Extension functions with side-effects and optimizat ions

Thanks for the comment. The working group will consider this, but meanwhile
here is a quick personal response from me.
 
I think it would be a good idea for us to strengthen the warning that
extension functions with side-effects are a bad idea, and that it is not
only unpredictable when they will be called, but whether they will be called
at all, and if so, how often. We should advise that it is not generally
possible for XSLT implementors to determine whether or not an extension
function has side-effects, and that the burden therefore falls squarely on
stylesheet authors. We should advise implementors either (a) to tell their
users not to use extension functions with side-effects at all, or (b) to
document clearly under what conditions such functions can safely be used, or
(c) to provide extensions (e.g. extension instructions) that enable the
evaluation of such functions to be controlled.
 
In the end, though, I don't think we can change the situation that (a) we
can't disallow such functions, and (b) we can't precisely define their
effect.
 
Michael Kay

-----Original Message-----
From: public-qt-comments-request@w3.org
[mailto:public-qt-comments-request@w3.org] On Behalf Of Kenneth Stephen
Sent: 03 January 2004 04:57
To: public-qt-comments@w3.org
Subject: [XSLT 2.0]Extension functions with side-effects and optimizations



Hi,

On the topic of extension functions with side-effects, the spec states :

"There is no prohibition on calling extension functions that have
side-effects (for example, an extension function that writes data to a
file). However, the order of execution of XSLT instructions is not defined
in this specification, so the effects of such functions are unpredictable."

An extension function with side-effects can also be utilized in other ways.
For example, a global variable can be defined as a child of the
xsl:stylesheet element and the "select" can invoke the extension function.
The side-effect in question could be something like the creation of a file
indicating that XSLT processing has been done on something else. One of the
major XSLT (1.0) processors around optimizes such global variables away if
the value of the variable isnt being used for anything. I had some
correspondance with one of its maintainer recently, and this is what he had
to say on the topic :

"That's sorta the nature of the beast, I'm afraid. XSLT is a functional
language, and that means that stuff can get executed out-of-sequence or
optimized away... and that's only going to become more common as we continue
to work on improving stylesheet efficiency. Extensions with side-effects are
problematic at best; they really should be thought of as extension Functions
in the pure sense of the term.

The only way to force evaluation of a variable is to use that variable's
value. There are a few kluges that folks have come up with to use it and
throw it away, but it can be tricky to find one that is guaranteed not to be
optimized out in the future."

This is a situation that doesnt seem to be explicitly addressed in the 2.0
spec. While out of order execution of extension functions may be kosher, is
it ok to completely optimize away the variable itself?

Thanks,
Kenneth Stephen

T/L 793-6462
(512)823-6462

Received on Sunday, 4 January 2004 14:46:34 UTC