-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maps & Arrays: Consistency & Terminology #1169
Comments
I'm fine with that.
The minimal set would probably be
Can't say I like the effect much. But I'm not happy with our over-use of
Yes that seems feasible. Now the other thing in my mind is to try and unify this with labels. If we deliver the results of a lookup as maps containing key + value, why shouldn't the result also contain accessor functions equivalent to the fields in a label: specifically parent() and ancestors()? The two features definitely have significant overlap. |
Sounds reasonable (I haven’t spent time on/with pins and labels yet, I should do so soon). Would |
The main benefit of these functions is probably as primitives that can be used to define the semantics of all the other functions concisely. For example we currently define array:join rather concisely as
Perhaps private functions could serve the same purpose. But if these functions are so useful as primitives, one feels that they would be useful tools for end-users as well. A reminder of how we got here: I started this journey by defining a |
I still find the (: array { } :)
array:of-members($sequence ! map { 'value': . })
(: map:build :)
array:of-members($input ! map { 'value': $action(.) })
(: map:append :)
array:of-members((array:members($array), map { 'value': $member }))
(: vs :)
array:join($sequence ! array { . })
array:join($input ! array { $action(.) })
array:join((array:split($array), array { $member })) Using a record constructor would possibly make the existing equivalencies, though.
True; I remember to have mentioned (one variant of) our Java binding that wraps object into function items and triggers the implicit conversion to XDM items by invoking the function item. The same could have been done with array members. However, maybe there are not really use cases left for which an additional parcel/function/record representation is still required:
I think we can already be happy if the newly added concepts are utilized by a considerable number of people. Maybe we should be careful not to overdo it, and maybe we should continue to appreciate the laudable 3.1 concepts of arrays (such as the powerful implicit atomization). |
If we drop map:merge(map:entries($map))
array:join(array:members($array)) This would feel intuitive to me, as the current spec terminology (as far as I can judge) regards array members as the counterparts of map entries. |
Indeed, the two function pairs |
Actually, I'm a bit confused about the spec of array:split. What is the result of The notes say
Which makes the result But this is only in the notes, and the actual rules are very informal; and none of the examples makes this clear. The only example that touches on it is the fourth example, and that one would work equally well if the result were More examples are needed, and the first note should be moved into the normative rules. |
Yes, that's supposed to be the result. Otherwise, the result could not be reversed (which is what I wanted to point out with “This function is the inverse of (: [ 1, 2, 3, 4 ] :)
array:join([ 1, 2 ],[ 3, 4 ])
True; sorry for that, and thanks for the hints. I still fail to understand what information is required to make the rules comprehensive enough (there are various functions, like |
As some of my suggestions in this thread are out of date, I suggest closing it. See #1338 for more recent comments. |
At meeting 095, the CG agreed to close this issue with no further action. |
After the introduction of #1094 and #1159, and before adding more map/array operations, I think it’s time to get more serious about consistency and terminology. The current drafts employ a variety of terms that are not clearly defined, or separated from each other. We now have at least…
…which are sometimes used for maps, for arrays, or for both data structures. A first attempt to clean up, with reducing the overall effort:
A minor one: The modifier for lookups should be in singular form, analagous to node axes:
item
,key
,value
,pair
.While I first advocated the orthogonality principle for axes in lookup expressions, I now think we should stick to the existing terminology. Otherwise, we would need to revise many other existing parts of the spec. My suggestion would be to:
member
for arrayskey
,value
andpair
for mapsitems
for both maps and arraysThis would make it symmetric with a) the current terminology for maps and arrays, and b) enhanced
for
clauses, i.e.for member $m
andfor key $k value $v
.The reverse approach would be to drop
for member $m
and to also allowfor key $k value $v
for arrays (withfor value
replacingfor member
). In addition, we could havefor pair
.With the introduction of the
item
axis,map:values
andarrays:values
should be renamed tomap:items
andarray:items
. →map:contents
andarray:contents
, see #1179I would suggest dropping
array:members
andarray:of-members
. The names don’t imply we’ll deal with records, and it’s not in line withfor member $m
either. If we want to keep these functions, we could rename them toarray:pairs
andarray:of-pairs
and add the integer positions as keys, and we should introduce and consistently use the termpair
for maps and arrays.Closely related: #826
The text was updated successfully, but these errors were encountered: