-
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
1685 Pipeline Operator #1686
1685 Pipeline Operator #1686
Conversation
I am in favour of adding this operator. My only reservation is about its operator precedence [Incidentally, it needs adding to the precedence table in A.5]. I can see the logic of a low precedence - the result of any expression can be piped into any other expression. But my instinct would have been to use the same precedence as |
I believe the analog with '1 2' -> tokenize(.) ! number() Instead, it would need to be: ('1 2' -> tokenize(.)) ! number() This seems counterintuitive, as this syntax implies that the parens are necessary to control the precedence, which is actually not the case. To look at it the other way: Can we think of use cases in which it would be confusing if |
I guess the biggest difference between Most of the time, the result will be the same either way. For example So it seems to be a case rather like I'm not sure I understand your example
If The main difference is going to show when the
while
I'm worried that the difference will lead to user confusion. |
True. I rather wanted to point out that… '1 2' => tokenize() ! number() …is not a valid syntax (it requires parens before the simple map operator), but that we should allow
Yes, I see. I think I will change the grammar to:
|
Thanks. I think that's the best solution. (We might also want to rename ArrowExpr to reflect the functionality rather than the visual form of the operator. But finding a good name is difficult, so let's put that on one side). |
@djbpitt I have revised the example section, maybe you find it helpful: https://qt4cg.org/pr/1686/xquery-40/xpath-40-autodiff.html#id-pipeline-operator |
Thank you for sharing these. The XQuery alternatives are welcome, but where the same logic could, alternatively, be expressed in XPath using just simple map (
Except for the last step I think this could be expressed idiomatically as:
The last step, though, makes a strong case because neither
works, but it requires parentheses around everything before the
Unless I've misunderstood something, this is equivalent to:
This does illustrate that
If I replace the 4.0
The only significant change I had to make was to swap the order of the arguments to The following also appears to work:
I like this last example because I cant think of a way with just I hope this is helpful. |
Thanks for the feedback; it is good to know that the revised examples are helpful. The alternative syntax should be both valid XPath and XQuery (but it may be counterintuitive that |
Issue: #1685
The PR introduces the pipeline operator
->
. If we decide to add it, we could drop=!>
in a second step and update various examples in the text.