[Bug 29080] array:members

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

--- Comment #7 from Abel Braaksma <abel.braaksma@xs4all.nl> ---
I think that whatever direct approach would be proposed (using a function),
there will always be surprising effects, both for map:values() and
array:values()/members(). And a syntax change in the CR phase has a large risk
of not being accepted.

To counter that, we could consider an alternative which is less obtrusive a
change to the spec:

I propose therefore to change the semantics of the SimpleMapExpr (!) slightly,
to allow the left-hand to be a singleton array or a singleton map. If it is an
array or map, the bang-operator loops over the items in the map or array
(setting the focus item, size and position to the respective member). 

If a given item in a map or array has size > 1, the function or operator on the
right-hand side must be able to deal with that, or an error is raised.

This approach has a couple of benefits:
1) It serves principle of least surprise ($arr ! name(.) will work as expected)
2) It is an unobtrusive change (I think) at this stage
3) It solves the problem raised in this bug report
4) It is easy to implement (I think)
5) It deals neatly with sequence concatenation and leaves it to the programmer
6) Easy to use in the typical case where items have arity zero-or-one
7) No backwards-compat issues, XP30 has no arrays and no maps
8) Solves quite a few use-cases, readable syntax

Down sides, surprises:
a) It has the effect that the rh-side can receive an empty seq (focus item of
size zero) if a member of array or map is an empty seq, which is otherwise not
possible. We could opt to skip such items, or allow this.
b) WG members may frown upon different business rules based on the type and
size of the left-hand operand (but the Lookup operator has similar differences)

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

Received on Saturday, 11 June 2016 14:26:48 UTC