Re: [xsl] [xslt 2.0] Local functions

Subject: Re: [xsl] [xslt 2.0] Local functions
From: Justin Johansson <procode@xxxxxxxxxx>
Date: Fri, 20 Jul 2007 10:29:21 +0900
>Michael Kay:
>Generally speaking, I think functions local to a function (or template) are
>not an especially good idea ...

>Dimitre Novatchev:
>As the need for local functions has never been expressed in this list
>for a period of 7 years, ...

Thanks guys, that was just the informed type of feedback I was seeking.

>Michael Kay:
> Anonymous functions would be a different question, if we had support
for higher-order functions in the language.

>Dimitre Novatchev:
>Having higher order functions (as provided by FXSL) eliminates the
>need for local functions. One can even create functions dynamically
>(by composition or by currying).

Dimitre, other than by composition or by currying, does FXSL support
arbitrary anonymous functions.

I've tossed a poor man's lambda into my library which ends up
calling saxon:evaluate().  Usage is something like this

s:map( s:l( 'some xpath expression which can operate on $p1'),
$sequence-of-values-id-like-to-translate-into-something-else)

e.g.

s:map( s:l( '$p1 * 2"),  $x)

returns $x with all values in the sequence doubled.

Yes, you could do that in FXSL by currying.


Justin Johansson
Now a Schema-Aware XSLT Evangelist

Current Thread