<div dir="ltr"><div>Dear Ghislain,</div><div><br></div>This I understand, but the only thing that bothers me is that the implicit binding of the first argument prevents the use of other arguments, whereas an explicit context would've allowed for the more flexible option of designating the argument yourself, while the arity would read more clearly:<div><br></div><div>$position => array:remove($array, .)</div><div><br></div><div>This difference with the simple mapping operator is what confuses and surprises me, but it seems I'm the only one, so let's just leave it at that.</div><div><br></div><div>Thanks a lot for your time.</div><div><br></div><div>Wouter<br><div class="gmail_extra"><br><div class="gmail_quote">2017-08-02 16:08 GMT+02:00 Ghislain  Fourny <span dir="ltr"><<a href="mailto:gfourny@inf.ethz.ch" target="_blank">gfourny@inf.ethz.ch</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Dear Wouter,<br>
<br>
Indeed, in some cases, whether to use => or ! can be subject to a matter of taste.<br>
<br>
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. The XPath and XQuery Functions and Operators 3.1 specification [1] explicitly gives a few examples:<br>
<br>
["a", "b", "c"] => array:get(2)<br>
<br>
$array => array:remove($position) => array:insert-before($position, $member)<br>
<br>
Kind regards,<br>
Ghislain<br>
<br>
[1] <a href="https://www.w3.org/TR/xpath-functions-31/" rel="noreferrer" target="_blank">https://www.w3.org/TR/xpath-<wbr>functions-31/</a><br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
<br>
> On 2 Aug 2017, at 12:09, W.S. Hager <<a href="mailto:wshager@gmail.com">wshager@gmail.com</a>> wrote:<br>
><br>
> That's why, for cases where it's possible, I preferred to write the simple mapping operator, as it's easier to read IMO.<br>
><br>
> 2017-08-02 12:07 GMT+02:00 W.S. Hager <<a href="mailto:wshager@gmail.com">wshager@gmail.com</a>>:<br>
> Hi Ghislain,<br>
><br>
> Alright, I forgot about fn:replace#4, but the implicit binding is sometimes hard to detect.<br>
><br>
> Thanks.<br>
><br>
><br>
> 2017-08-02 12:04 GMT+02:00 Ghislain Fourny <<a href="mailto:gfourny@inf.ethz.ch">gfourny@inf.ethz.ch</a>>:<br>
> ... I didn't get it quite right actually. In @address => string(), there is no context item involved, I wrote too fast. :-)<br>
><br>
> New attempt:<br>
><br>
> @address ! string(.) (: explicitly passed context item :)<br>
> @address ! string() (: context item passed implicitly to string#0, which is context-dependent)<br>
> @address => string() (: @address passed implicitly to string#1 as the first parameter via the => operator, but string#1 is context-independent)<br>
> @address => string(.) (: error: string#2 does not exist :)<br>
><br>
> Kind regards,<br>
> Ghislain<br>
><br>
><br>
> > On 2 Aug 2017, at 12:00, Ghislain Fourny <<a href="mailto:gfourny@inf.ethz.ch">gfourny@inf.ethz.ch</a>> wrote:<br>
> ><br>
> > Dear Wouter,<br>
> ><br>
> > There is one more important difference on the syntactic level.<br>
> ><br>
> > With the arrow operator, the left-hand-side is implicitly bound to the first parameter of the function.<br>
> ><br>
> > @address => replace(@postcode, "", "q")<br>
> ><br>
> > is the same as<br>
> ><br>
> > replace(@address, @postcode, "", "q")<br>
> ><br>
> ><br>
> > With the simple map operator, the context item must be explicitly referred to, like so:<br>
> ><br>
> > @address ! replace(., @postcode, "", "q")<br>
> ><br>
> ><br>
> > What may create confusion is that some functions have several signatures, some of which implicitly refer to the context item. But this is a very different mechanism.<br>
> ><br>
> > For example :<br>
> ><br>
> > @address ! string(.) (: explicitly passed context item :)<br>
> > @address ! string() (: context item passed implicitly to string#0, which is context-dependent)<br>
> > @address => string() (: context item passed implicitly to string#1 via the => operator, but string#1 is context-independent)<br>
> ><br>
> > I hope I got it right!<br>
> ><br>
> > Kind regards,<br>
> > Ghislain<br>
> ><br>
> ><br>
> >> On 2 Aug 2017, at 11:27, W.S. Hager <<a href="mailto:wshager@gmail.com">wshager@gmail.com</a>> wrote:<br>
> >><br>
> >> Hi Michael,<br>
> >><br>
> >> The way you used the arrow operator in the example would be the way I expected it to work, namely by explicitly addressing the context, but it seems that it doesn't. It's actually implicitly binding the first argument of the function on the right to the value on the left. Or is there an exception I don't know about?<br>
> >><br>
> >> Thanks.<br>
> >><br>
> >> Op 1 aug. 2017 18:58 schreef "Michael Kay" <<a href="mailto:mike@saxonica.com">mike@saxonica.com</a>>:<br>
> >> In the case of singletons there's very little difference, but (as I now see Christian has pointed out), with sequences the effect is quite different.<br>
> >><br>
> >> Also, of course, "!" changes the context item, so<br>
> >><br>
> >> @address => replace(@postcode, "", "q") works, while<br>
> >><br>
> >> @address ! replace(@postcode, "", "q") doesn't.<br>
> >><br>
> >> Michael Kay<br>
> >> Saxonica<br>
> >><br>
> >>> On 1 Aug 2017, at 13:27, W.S. Hager <<a href="mailto:wshager@gmail.com">wshager@gmail.com</a>> wrote:<br>
> >>><br>
> >>> Hi,<br>
> >>><br>
> >>> Is there any advantage to using the 3.1 arrow operator over the simple map operator?<br>
> >>><br>
> >>> $string => upper-case() => normalize-unicode() => tokenize("\s+")<br>
> >>><br>
> >>> versus<br>
> >>><br>
> >>> $string ! upper-case(.) ! normalize-unicode(.) ! tokenize(.,"\s+")<br>
> >>><br>
> >>> Thanks,<br>
> >>> Wouter<br>
> >>> ______________________________<wbr>_________________<br>
> >>> <a href="mailto:talk@x-query.com">talk@x-query.com</a><br>
> >>> <a href="http://x-query.com/mailman/listinfo/talk" rel="noreferrer" target="_blank">http://x-query.com/mailman/<wbr>listinfo/talk</a><br>
> >><br>
> >><br>
> >> ______________________________<wbr>_________________<br>
> >> <a href="mailto:talk@x-query.com">talk@x-query.com</a><br>
> >> <a href="http://x-query.com/mailman/listinfo/talk" rel="noreferrer" target="_blank">http://x-query.com/mailman/<wbr>listinfo/talk</a><br>
> ><br>
><br>
><br>
><br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br><div class="gmail_signature"><div><p><br></p></div></div>
</div></div></div>