This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Inline functions in XQuery are verbose. Consider fn:sort($employees, function($emp as element(employee)) { $emp/@salary }) Programming in a purely function style becomes a lot easier with a compact syntax for writing inline functions. Compare: XQuery (1) function($x as xs:integer, $y as xs:integer) { $x + $y } XQuery (2) function($x, $y) {$x + $y} Javascript 6 (x, y) => x+y Java 8 (int x, int y) -> x+y Scala (1) (x: Int, y: Int) => x + y Scala (2) _ + _ Haskell \ x y -> x + y Python lambda x, y: x + y A couple of suggestions: (a) Many use cases for simple inline functions take a single item as argument, and we could exploit the existing use of "." for the context item for such cases. For example use \{. + 1} as shorthand for function($x as item()){$x/(. + 1)} allowing constructs such as fn:sort($employees, \{@salary}) (b) For functions without declared types, we could implicitly declare the arguments as $1, $2, etc: \{$1 + $2} allowing fn:sort($employees, \{$1/@salary}) Or we could combine the two ideas with "." being a synonym for ($1 treat as item()), thus fn:sort($employees, \{@salary}) I'm not wedded to the backslash. Alternatives to \{$1+2} would be fn{$1+$2} or {|$1+$2|} or even bare {$1+$2}.
\{$1 + $2} looks awesome. Although you cannot set a type for $123. But types on anonymous functions are only causing a mess with function coercion anyways {|$1+$2|} is very bad. It is the JSONiq object merge syntax. And the bare {$1+$2} would be confused with JSONiq object creation.