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


--- Comment #2 from Michael Kay <mike@saxonica.com> ---
I did not intend to reopen the discussion about the semantics of [a,b,c]. I
think we got it right in Prague: it creates an array with three members, these
being the values of a, b, and c. I think that's what most people would expect,
as we discussed in Prague many languages have such a construct and they
invariably create an array with N+1 members where N is the number of commas. We
can't do this with a function call unless it is a variable-arity function call.

I'm concerned here with the other construct, array{X}. I want to understand
whether there is a good reason for having custom syntax for this, rather than
using a function call as we do with its inverse, seq(X).

I see this being used in situations like

array {
  for $x in employee
  return $x/salary/data()

and perhaps this is why curlies were chosen; the FLWOR looks more like a
statement than an expression to people from other cultures, because of its
sentential syntax, and in those cultures curly braces are used to group
"statements". But that's not our culture; we have an expression language, and
array{} is semantically a pure function call. Making it a pure function allows
things like

(a/b/c) => array()

which people will increasingly expect to be able to write.

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

Received on Friday, 25 April 2014 14:47:18 UTC