[Bug 21963] New: Implicit iteration on dynamic function calls

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 21963] New: Implicit iteration on dynamic function calls

Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21963

            Bug ID: 21963
           Summary: Implicit iteration on dynamic function calls
    Classification: Unclassified
           Product: XPath / XQuery / XSLT
           Version: Candidate Recommendation
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XPath 3.0
          Assignee: [hidden email]
          Reporter: [hidden email]
        QA Contact: [hidden email]

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?

--
You are receiving this mail because:
You are the QA Contact for the bug.

Reply | Threaded
Open this post in threaded view
|

[Bug 21963] Implicit iteration on dynamic function calls

Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21963

Michael Kay <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email]

--- Comment #1 from Michael Kay <[hidden email]> ---
What is "the ML"?

--
You are receiving this mail because:
You are the QA Contact for the bug.

Reply | Threaded
Open this post in threaded view
|

[Bug 21963] Implicit iteration on dynamic function calls

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21963

--- Comment #2 from Ghislain Fourny <[hidden email]> ---
The Mailing List :-) I should be more parsimonious with abbreviations.

--
You are receiving this mail because:
You are the QA Contact for the bug.

Reply | Threaded
Open this post in threaded view
|

[Bug 21963] Implicit iteration on dynamic function calls

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21963

--- Comment #3 from Jonathan Robie <[hidden email]> ---
I like this.  It's a little tricky to fit into the current structure of the
spec, and I'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.

<old>
If FC is a dynamic function call: FC'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].
</old>

<new>
If FC is a dynamic function call: FC'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. <add>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].
</new>

--
You are receiving this mail because:
You are the QA Contact for the bug.

Reply | Threaded
Open this post in threaded view
|

[Bug 21963] Implicit iteration on dynamic function calls

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21963

--- Comment #4 from Michael Kay <[hidden email]> ---
I'm against doing this.

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

An argument against is as follows: Suppose we have a map of functions (XDM'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 "multiply", the "?" selector selects no function and you
get an empty sequence back rather than an error.

--
You are receiving this mail because:
You are the QA Contact for the bug.

Reply | Threaded
Open this post in threaded view
|

[Bug 21963] Implicit iteration on dynamic function calls

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21963

--- Comment #5 from Jonathan Robie <[hidden email]> ---
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 := ( { "a" : 1 }, { "b" : 2 }, { "c" : 3 } )
return $maps("b")

Currently, that raises an error. This does not:

let $maps := ( { "a" : 1 }, { "b" : 2 }, { "c" : 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.

--
You are receiving this mail because:
You are the QA Contact for the bug.

Reply | Threaded
Open this post in threaded view
|

[Bug 21963] Implicit iteration on dynamic function calls

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21963

--- Comment #6 from Ghislain Fourny <[hidden email]> ---
Hi,

I agree with Jonathan'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

--
You are receiving this mail because:
You are the QA Contact for the bug.

Reply | Threaded
Open this post in threaded view
|

[Bug 21963] Implicit iteration on dynamic function calls

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21963

Tim Mills <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email]

--- Comment #7 from Tim Mills <[hidden email]> ---
Could the syntax

 $maps?b

be extended to allow

  $maps?{ Expr }

(a bit like element constructors).

--
You are receiving this mail because:
You are the QA Contact for the bug.

Reply | Threaded
Open this post in threaded view
|

[Bug 21963] Implicit iteration on dynamic function calls

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21963

--- Comment #8 from Michael Kay <[hidden email]> ---
The syntax already allows

$maps?(Expr)

--
You are receiving this mail because:
You are the QA Contact for the bug.

Reply | Threaded
Open this post in threaded view
|

[Bug 21963] Implicit iteration on dynamic function calls

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21963

--- Comment #9 from Jonathan Robie <[hidden email]> ---
Brief history of this issue.

* JSONiq has always done iteration on sequences of maps using function call
syntax.
* Iteration for the "?" 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 "?" 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.

--
You are receiving this mail because:
You are the QA Contact for the bug.

Reply | Threaded
Open this post in threaded view
|

[Bug 21963] Implicit iteration on dynamic function calls

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21963

--- Comment #10 from Jonathan Robie <[hidden email]> ---
At this point, I'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

--
You are receiving this mail because:
You are the QA Contact for the bug.

Reply | Threaded
Open this post in threaded view
|

[Bug 21963] Implicit iteration on dynamic function calls

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21963

Jonathan Robie <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--
You are receiving this mail because:
You are the QA Contact for the bug.