Subject: RE: [xsl] XSLT 2.0: Are arguments to functions evaluated eagerly or lazily? From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 18 Jul 2007 08:41:20 +0100 |
> Supposing you have a function that is passed two arguments, > say, a condition argument, test, and an argument, value, > that returns value if test is true and the empty sequence > otherwise, is the value argument evaluated at the time of > calling the function if the test argument is false? The spec leaves this question open - the implementation can do either. > are there any XSLT > 2.0 processors which do evaluate lazily? Yes, Saxon does so (usually!). There are exceptions, for example if the expression used in a function contains a call to the function being called (which is one particular coding pattern for doing recursion) then the expression is evaluated on the caller's stack rather than the callee's because this can prevent stack overflow when the recursion gets deep. > > It would be really nice to be able apply this idiom to a > whole series of logical functions*** without suffering a huge > performance hit. If your processor doesn't do a certain amount of lazy evaluation, then you're going to take a huge performance hit every time you write xx[1]. But for this particular case, I can't see that you're achieving any useful brevity or abstraction by writing select="f:cond(condition, value)" rather than select="if (condition) then value else ()". Michael Kay http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSLT 2.0: Are arguments t, Colin Adams | Thread | RE: [xsl] XSLT 2.0: Are arguments t, Justin Johansson |
RE: [xsl] function-available() test, Michael Kay | Date | RE: [xsl] XSLT 2.0: Saxon et. al.: , Michael Kay |
Month |