Re: Evaluation function

I was also one of the "one or two of us" who were pushing for this.

Another reason given for delaying is that some people felt second order 
functions are more important than eval(), and there is an overlap in the 
usage scenarios.

But eval() can do some things second-order functions can't, such as 
executing an XQuery expression stored in data.

Jonathan

Michael Kay wrote:

> There is no standard function to do this.
>  
> A number of XSLT processors (Saxon was the first) have provided an 
> evaluate() function to fill this gap - there is a semi-standardized 
> specification at www.exslt.org <http://www.exslt.org>. Unfortunately 
> Saxon's version, saxon:evaluate() is not currently available via the 
> XQuery interface, only via XSLT. I don't think there's a good technical 
> reason for this restriction, it's mainly a question of testing.
>  
> One or two of us did push quite hard for a standard evaluate() function, 
> but the WG decided against. The main arguments, if I recall, were (a) 
> that it broke type safety, (b) that some processors use a compilation 
> architecture in which the parser isn't available at run-time, and (c) 
> that it's not obvious how much of the static/dynamic context should be 
> available to the evaluated expression.
>  
> (At least you understand what it is that you're asking for! A lot of 
> XSLT users have stumbled into this without knowing what they are doing, 
> they try to write things like a[$x] where $x is the string "@foo='bar'" 
> I think the problem is that the use of $ to introduce variables is 
> associated in some people's minds with macro languages).
>  
> Michael Kay

Received on Friday, 23 July 2004 06:04:10 UTC