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
1159 Add filter expressions for maps and arrays #1163
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nice proposal…
- Maybe
$value?[predicate]
could be changed tovalue?[predicate]
, as the first variant implies that the value must be a variable reference. - It’s ok that numeric predicates are not supported, but I didn’t understand the reasoning. My assumption would be that
$array?[1, 3]
and$array?[position() = (1, 3)]
are simply equivalent. - Typo:
specificd
Fix #1159 |
I dropped numeric predicates because I felt people would expect |
Would an implementation then be allowed to return the full array for Ironically, people might still write (: valid :)
$array?[position() = 1]
$array?[true()]
[true()]?[?1]
['a']?[boolean(?1)]
(: invalid :)
$array?[1]
$array?['a']
$array?[./a]
['a']?[?1] |
Minor detail: should "?[" be one token or two? I can't see any strong arguments either way. Making it one token gives us a bit more flexiibility to change the operator precedence, but I don't see any particular reason to do that. |
I have no preference either. I’m convinced that I would use the new syntax once it existed… but I can’t quite get used to the fact that we treat arrays and maps differently (this runs counter to our efforts to standardize the two data structures). Next, while the classical filter expression is comparatively clean, we now run the risk of doing a lot of special casing. For expressions like… $map-or-array?[. = 123]
$map-or-array?[?key = 123] …there will be no chance to raise static errors. |
The CG agreed to merge this issue at meeting 074 |
No description provided.