[xquery-talk] eval in XQuery implementations
mike at saxonica.com
Tue May 31 13:57:23 PDT 2011
On 31/05/2011 18:20, Adam Retter wrote:
> We support eval() in eXist-db and have a number of over loaded
> functions which allow you to manipulate the context for the eval, e.g.
> inherit, new or some other context...
> IMHO eval() is a very very evil thing and can usually be avoided
> through the provision of a set of 'parse' functions and some functions
> that enable you to construct dynamic HoF calls...
> It is my goal to eventually remove eval() from eXist-db once HoF in
> 3.0 settles down and is proven in use.
It's true enough that the equivalent exslt:evaluate() has often been
abused as a poor man's substitute for higher order functions. On the
other hand there are also some very legitimate use cases. If you want a
user interface that provides a form-based query (like the search
interface in Bugzilla) by far the easiest way to do it is to construct a
dynamic query. I've also seen examples where XPath expressions defining
business rules were held in a configuration file for ease of editing and
interpreted by the XSLT processor; it's hard to argue that this was a
It would be easier to argue against eval() in XQuery if there weren't so
many things in the language that are impossible to specify dynamically,
like the collation for sorting or the choice of ascending/descending.
More information about the talk