<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26889</bug_id>
          
          <creation_ts>2014-09-23 11:28:25 +0000</creation_ts>
          <short_desc>Extending the arrow operator</short_desc>
          <delta_ts>2014-11-20 11:32:25 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XQuery 3.1</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          <see_also>https://www.w3.org/Bugs/Public/show_bug.cgi?id=26585</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Christian Gruen">christian.gruen</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>andrew_coleman</cc>
    
    <cc>cmsmcq</cc>
    
    <cc>john.snelson</cc>
    
    <cc>josh.spiegel</cc>
    
    <cc>leo</cc>
    
    <cc>liam</cc>
    
    <cc>mike</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>112011</commentid>
    <comment_count>0</comment_count>
    <who name="Christian Gruen">christian.gruen</who>
    <bug_when>2014-09-23 11:28:25 +0000</bug_when>
    <thetext>I decided to open a new issue for discussing Leo Wörteler&apos;s proposal on extending the arrow operator (https://www.w3.org/Bugs/Public/show_bug.cgi?id=26585). I believe that the extension would make the operator more consistent with the existing functional semantics of XQuery:


Leo Wörteler, 2014-09-11 15:22:04 UTC:

The current implementation of the arrow operator in the Working Draft [1] defines it as a syntactic macro:

&gt; If `$i` is an item and `f()` is a function, then `$i=&gt;f()` is equivalent
&gt; to `f($i)`, and `$i=&gt;f($j)` is equivalent to `f($i, $j)`.

I think this is not very elegant and possibly confusing. Since e.g. `local:foo#0` and `local:foo#1` can be completely different functions in XQuery, it is potentially dangerous that in

  1 =&gt; local:bar() =&gt; local:foo()

it is not immediately obvious which of them is called.

I would propose that the second argument of `=&gt;` should instead be a function item taking one argument. Then `$arg =&gt; $f` can be translated into `$f($arg)` directly and the Spec can define it simply as equivalent to:

  function op:arrow-apply(
    $arg as item()*,
    $func as function(item()*) as item()*
  ) as item()* {
    $func($arg)
  };

As a nice bonus this also makes the feature more flexible because the argument to be inserted does not have to be the first one in the function:

  $file-extension =&gt; csv:get-separator() =&gt; (tokenize($line, ?))()

could be written as

  $file-extension =&gt; csv:get-separator#1 =&gt; tokenize($line, ?)

Everything that was possible before should still work when adding a &quot;?&quot; at the start of the ArgumentList of each right-hand side of `=&gt;`. The example from the Spec becomes

  $string =&gt; upper-case(?) =&gt; normalize-unicode(?) =&gt; tokenize(?, &quot;\s+&quot;)

or (shorter and more elegant):

  $string =&gt; upper-case#1 =&gt; normalize-unicode#1 =&gt; tokenize(?, &quot;\s+&quot;)

In conclusion, using function items is more flexible and less confusing, and the syntactic translation scheme makes for only marginally less verbose tyntax.

[1] http://www.w3.org/TR/2014/WD-xquery-31-20140424/#id-arrow-operator</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112013</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-09-23 11:45:41 +0000</bug_when>
    <thetext>I don&apos;t think this is an improvement. 

We&apos;ve designed the function library so that in nearly all cases the first argument is in some sense the &quot;primary input&quot;, and there&apos;s no need for it to be immediately apparent which arity of a function is being called, because all the functions with a given name do very similar things to the primary input; we would expect any well-designed function library to behave in a similar way. So adding the requirement to include the &quot;?&quot; placeholder in the function call on the rhs adds noise without doing anything useful.

One drawback of the proposal is that it makes &quot;=&gt;&quot; dependent on higher-order functions, which is (a) an optional feature, and (b) a feature that many casual users of XPath may want to steer clear of because they don&apos;t understand it. (Florent had great trouble getting the ideas across to an audience of experienced XSLT users at the summer school last week...)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112017</commentid>
    <comment_count>2</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2014-09-23 14:07:13 +0000</bug_when>
    <thetext>I agree with Mike Kay completely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114185</commentid>
    <comment_count>3</comment_count>
    <who name="C. M. Sperberg-McQueen">cmsmcq</who>
    <bug_when>2014-10-28 21:35:27 +0000</bug_when>
    <thetext>It makes me nervous to disagree with both Michael Kay and Jonathan Robie, but I have to say that the proposal seems to me a marked improvement on the status quo.  It&apos;s easier to understand, and it&apos;s easier to write.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114186</commentid>
    <comment_count>4</comment_count>
    <who name="Josh Spiegel">josh.spiegel</who>
    <bug_when>2014-10-28 21:48:07 +0000</bug_when>
    <thetext>I don&apos;t want &quot;=&gt;&quot; to depend on the optional HOF feature.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114187</commentid>
    <comment_count>5</comment_count>
    <who name="Liam R E Quin">liam</who>
    <bug_when>2014-10-28 21:48:37 +0000</bug_when>
    <thetext>Note that the current syntax
(1) does not require the optional higher-order function feature;
(2) parallels the foo/bar/baz() syntax in XPath, where the last step can
    be a function.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114188</commentid>
    <comment_count>6</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2014-10-28 21:55:21 +0000</bug_when>
    <thetext>(In reply to Josh Spiegel from comment #4)
&gt; I don&apos;t want &quot;=&gt;&quot; to depend on the optional HOF feature.

+1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115062</commentid>
    <comment_count>7</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2014-11-18 17:16:02 +0000</bug_when>
    <thetext>I think extra commas and question marks reduce the benefit of the arrow operator as syntactic sugar.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115205</commentid>
    <comment_count>8</comment_count>
    <who name="Andrew Coleman">andrew_coleman</who>
    <bug_when>2014-11-20 11:24:25 +0000</bug_when>
    <thetext>It was decided by the Working Group in the 2014-11-18 teleconference not to adopt this proposal into XQuery 3.1 for the reasons outlined in previous comments.  The proposal referenced from this in bug 26585 (https://www.w3.org/Bugs/Public/show_bug.cgi?id=26585) is being considered by the Working Group separately.
Many thanks for the suggestion and discussion.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115208</commentid>
    <comment_count>9</comment_count>
    <who name="Christian Gruen">christian.gruen</who>
    <bug_when>2014-11-20 11:32:25 +0000</bug_when>
    <thetext>Thanks as well for the numerous comments on this proposal.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>