Arrays and maps: consistency #1871
Labels
Enhancement
A change or improvement to an existing feature
Propose for V4.0
The WG should consider this item critical to 4.0
XQFO
An issue related to Functions and Operators
Suggestions (based on #1338, related: #1868)
pairs
lookup specifier, we should addarray:pairs
and an inversearray:of-pairs
function.values
lookup specifier, we should addarray:values
andmap:values
functions, to retrieve the values of maps and the members of arrays in a sequence of arrays.array:members
andarray:of-members
seem redundant, and we should drop them.keys
specifier andmap:keys
, we should addarray:keys
(which returns a dense integer range).Background
With version 4.0, we are adding a lot of promising and powerful new map and array features. This is a big step forward, compared to the obvious limitations of 3.1.
Some aspects of the 3.1 design have made it difficult (or impossible) to fully adjust array and maps, but (in my opinion) the old overall concept was impressively consistent – and it is definitely a big challenge to achieve a 4.0 design that is not too fragmented.
To me, this becomes particularly evident in the case of arrays. The following example sums up the items of all members of an array. For the cumbersome 3.1 solution…
…we now have several (roughly?) equivalent options to do this:
for member $m in $array return sum($m)
array:members($array) ! sum(?value)
$array?pairs::* ! sum(?value)
$array?values::* ! sum(.)
The examples above imply that:
array:pairs
);array:values
).The text was updated successfully, but these errors were encountered: