<?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>21963</bug_id>
          
          <creation_ts>2013-05-08 07:57:19 +0000</creation_ts>
          <short_desc>Implicit iteration on dynamic function calls</short_desc>
          <delta_ts>2015-01-05 14:32:15 +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>XPath 3.1</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <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="Ghislain Fourny">g</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>mike</cc>
    
    <cc>tim</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>87409</commentid>
    <comment_count>0</comment_count>
    <who name="Ghislain Fourny">g</who>
    <bug_when>2013-05-08 07:57:19 +0000</bug_when>
    <thetext>Last year, it was briefly discussed on the ML whether to support dynamic function calls on sequences of functions (with an implicit iteration).

https://lists.w3.org/Archives/Member/w3c-xsl-query/2012Sep/0005.html

Zorba does support this, on the grounds that it would be consistent with an XPath-like navigation on maps (3.1). Having the same behaviour (i) for both functions and maps/objects and (ii) for both 3.0 and 3.1 would simplify the implementation.

It would be nice if we could discuss relaxing this in a call, if it is not too disruptive for the CR period?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87412</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-05-08 08:37:37 +0000</bug_when>
    <thetext>What is &quot;the ML&quot;?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87415</commentid>
    <comment_count>2</comment_count>
    <who name="Ghislain Fourny">g</who>
    <bug_when>2013-05-08 11:38:59 +0000</bug_when>
    <thetext>The Mailing List :-) I should be more parsimonious with abbreviations.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105856</commentid>
    <comment_count>3</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2014-05-13 14:59:42 +0000</bug_when>
    <thetext>I like this.  It&apos;s a little tricky to fit into the current structure of the spec, and I&apos;d like to avoid restructuring this part. My first thought is to do something along these lines:


3.1.5.1 Evaluating Static and Dynamic Function Calls

2.b. 

&lt;old&gt;
If FC is a dynamic function call: FC&apos;s base expression is evaluated with respect to SC and DC. If this yields a sequence consisting of a single function with the same arity as the arity of the ArgumentList, let F denote that function. Otherwise, a type error is raised [err:XPTY0004].
&lt;/old&gt;

&lt;new&gt;
If FC is a dynamic function call: FC&apos;s base expression is evaluated with respect to SC and DC. If this yields a sequence consisting of a single function with the same arity as the arity of the ArgumentList, let F denote that function. &lt;add&gt;If it yields a sequence of functions with the same arity as the arity of the ArgumentList, let F denote each of these functions in turn, in the order of the sequence. Otherwise, a type error is raised [err:XPTY0004].
&lt;/new&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106456</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-05-20 16:13:25 +0000</bug_when>
    <thetext>I&apos;m against doing this.

I think the main use case is for selection from an array of maps. This can be done using the &quot;?&quot; operator: employees[?location=&apos;Germany&apos;]?surname.

An argument against is as follows: Suppose we have a map of functions (XDM&apos;s equivalent of an object); so for example $complex?multiply($c1, $c2) selects the multiply function on complex numbers. The effect of this proposal would be that if you misspell &quot;multiply&quot;, the &quot;?&quot; selector selects no function and you get an empty sequence back rather than an error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106843</commentid>
    <comment_count>5</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2014-05-27 14:59:13 +0000</bug_when>
    <thetext>I agree that the main use case is selection from a sequence of maps (it also applies to arrays). A sequence of maps can occur because:

* The result of a query on JSON is a sequence of maps
* FLWOR expressions create sequences of maps
* Maps occur in a collection
* A view of relational or object data creates sequences of maps

Consider the following example:

let $maps := ( { &quot;a&quot; : 1 }, { &quot;b&quot; : 2 }, { &quot;c&quot; : 3 } )
return $maps(&quot;b&quot;)

Currently, that raises an error. This does not:

let $maps := ( { &quot;a&quot; : 1 }, { &quot;b&quot; : 2 }, { &quot;c&quot; : 3 } )
return $maps?b

We currently have two syntaxes that mostly do the same thing, one iterates but can never support all keys, the other supports all keys but does not iterate. That makes the language confusing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106904</commentid>
    <comment_count>6</comment_count>
    <who name="Ghislain Fourny">g</who>
    <bug_when>2014-05-28 09:36:51 +0000</bug_when>
    <thetext>Hi,

I agree with Jonathan&apos;s assessment. I think that resilience in case of heterogeneity in the input sequence is important (i.e., return an empty sequence rather than raise an error), and follows the XPath paradigm as well. I also think that consistency between function calls and the ? syntax would be nice.

This is of course the view from a database/document-store perspective. I am afraid that this is another example where the use case scenario affects the design decision: if we reason data-oriented (NoSQL), then iterating makes sense (even with functions in the data). If we reason pure map-oriented (i.e., equivalent of objects as Mike mentions), then raising an error makes sense.

I hope it helps.

Kind regards,
Ghislain</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107111</commentid>
    <comment_count>7</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2014-06-02 06:19:57 +0000</bug_when>
    <thetext>Could the syntax

 $maps?b

be extended to allow

  $maps?{ Expr }

(a bit like element constructors).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107113</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2014-06-02 07:36:28 +0000</bug_when>
    <thetext>The syntax already allows

$maps?(Expr)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107169</commentid>
    <comment_count>9</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2014-06-03 00:22:18 +0000</bug_when>
    <thetext>Brief history of this issue.

* JSONiq has always done iteration on sequences of maps using function call syntax.
* Iteration for the &quot;?&quot; operator was one of the variants in https://lists.w3.org/Archives/Member/w3c-xsl-query/2014Feb/0112.html
* We decided to adopt iteration for the &quot;?&quot; operator in meeting #564 https://lists.w3.org/Archives/Member/w3c-xsl-query/2014Mar/0020.html
* That decision is reflected in the First Public Working Draft.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107945</commentid>
    <comment_count>10</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2014-06-17 15:52:08 +0000</bug_when>
    <thetext>At this point, I&apos;m inclined to think we do not need this if we extend the ? operator to both maps and arrays, as in this proposal:

https://lists.w3.org/Archives/Member/w3c-xsl-query/2014Jun/0022.html (member only)

Or possibly this proposal, which does not use that character:

https://lists.w3.org/Archives/Member/w3c-xsl-query/2014Jun/0010.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116788</commentid>
    <comment_count>11</comment_count>
    <who name="Ghislain Fourny">g</who>
    <bug_when>2015-01-05 14:32:15 +0000</bug_when>
    <thetext>I agree with the WG decision that having ? do this addresses the issue at hand.

Thanks!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>