ISSUE: Why no higher-order functions?

Summary: Please add higher-order functions.


XQuery is a functional language.  Most functional languages have
higher-order functions (functions that can be stored in variables, and
passed as arguments to other functions), and these provide a powerful
mechanism for abstraction and expression that is nearly impossible to
get otherwise.

Many functions I would like to write demonstrate the need.  For
example, if I wanted to write a sort() function as an XQuery library,
I would not be able to parameterize it using a comparison function.
Thus, I'd need to re-write the entire sort() function for every
datatype I wanted to sort.  This seems unreasonable.


The syntax for XQuery demonstrates the need.  Many of the syntactic
constructs in XQuery could more pleasantly and easily be done with the
addition of higher-order functions.  'sortby', 'some', and 'every'
expressions spring to mind immediately.  In addition, if I wanted to
write new, similar functionality, I'd be out of luck.  Adding new
syntax for each slight variant of a mechanism seems overkill.


The community seems to recognize the need.  Also, witness the fact
that shortly after XSLT was released, the need for higher-order
functions was seen as useful enough to be integrated into Saxon as
well as into the EXSLT spec.  So there's user demand.


In summary, the lack of higher-order functions seems a crippling
disability to XQuery, and there is much need, as demonstrated by use
cases, the XQuery syntax itself, and the community.  Please consider
adding higher-order functions to XQuery.


Thank you for your time.

       -Shawn Vincent.



--
Shawn Vincent, svincent@exalt.com
Exalt Inc.

Received on Monday, 14 January 2002 10:34:51 UTC