[Bug 25445] [XP3.1] Replace curly array constructor with a function

https://www.w3.org/Bugs/Public/show_bug.cgi?id=25445

--- Comment #1 from Jonathan Robie <jonathan.robie@gmail.com> ---
The only reason we have two syntaxes is that we want one of these syntaxes to
use commas the same way functions do, and we want the other to accept an
arbitrary sequence and create an array whose members are the items in the
sequence.

The square array constructor uses commas the same way that functions do, commas
delimit the members of the resulting array. If we were to use function syntax
for an array constructor, this would be a better candidate. 

The curly array constructor takes an arbitrary expression and creates an array
with one member for each item in the sequence. It does not use commas the same
way as function calls, a comma is a comma operator.

One of the use cases creates an array of maps. The current solution uses
JSONiq, so the square array constructor has the same semantics as our curly
array constructor:

[
  for $w in $s()
  return { "pos" : $w(2), "lemma" : $w(1) }
]

Creating arrays of maps or maps of arrays will be common when working with
JSON. But with our current square constructor, this expression creates an array
with one member, a sequence of maps. I was not happy with that decision. JSON
doesn't even allow that structure, and I expect this to be a common mistake for
people working with JSON.

I think your suggestion is probably backwards. We need one syntax in which the
comma delimits arguments the same way as commas in function calls. Lets use
function call syntax for that. We need another syntax in which the items in an
arbitrary sequence are used as the members of an array. Function call syntax
doesn't work well for that.

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

Received on Friday, 25 April 2014 13:59:03 UTC