[xquery-talk] arrow operator
W.S. Hager
wshager at gmail.com
Thu Aug 3 12:46:23 PDT 2017
Hi Michael,
Anonymous functions would've been quite nice, but could your example only
be used for a single argument?
Op 2 aug. 2017 17:44 schreef "Michael Kay" <mike at saxonica.com>:
>
> To put things in perspective, => was introduced in version 3.1, together
with map and array support. As far as I understand it and looking again at
the specs, one of the use cases is for => to be used with maps and arrays,
in an object-oriented style.
In particular, arrays don't have a filter operator in the way that
sequences do, neither do they have a mapping operator, so to select into an
array of maps you need to do things like
$A => a:filter( function($m) {$m?name='Mike'}) => a:for-each( function($m)
{ $m?age })
which gets terribly unwieldy if you try to write it with conventional
nested function calls.
I wish we had done a concise anonymous function declaration as well:
$A => a:filter( {?name='Mike'} ) => a:for-each( {?age} )
Here {EXPR} is shorthand for "function($x){ $x ! EXPR }"
but that would have been a bridge too far for some people.
Michael Kay
Saxonica
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://x-query.com/pipermail/talk/attachments/20170803/2768b726/attachment.html>
More information about the talk
mailing list