-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: replace all redirection operators with x |> redirect(y)
#10211
Conversation
For more brevity, we could call this |
The problem is that right now you can't predict when it will work to rewrite |
Personally I dislike that too and would be just as happy to find another way for people to write pipelines. |
I'm a bit skeptical of how important it is to have
It's actually shorter than my example above, even without renaming |
I far prefer that, actually. It would also be possible to add pipe syntax inside of backticks, which would be more user-friendly anyway. |
How about instead of this |
Yes, that's pretty much what I was getting at. So far I think that's the best approach. |
Getting rid of the |
ed5b7a4
to
11cd2dc
Compare
Ok, I tried this and I like it even more than I thought I would. It is just so simple and regular. Multi-step pipelines are bit awkward, but overall this is great. |
Yes, much better – the multistep case seems like it could be handled by a n-arg version of |
+1 |
Yes please. Can this be compat-ed easily? |
Yes, very easily. I'll add deprecations. |
Can we please hold off on that? I'm not at all convinced that it's a good idea. I just don't feel like we're getting enough out of that syntax to do this. |
Everybody ok to merge this? |
DO IT |
RFC: replace all redirection operators with `x |> redirect(y)`
that travis failure's sorta scary but pretty sure it's unrelated https://travis-ci.org/JuliaLang/julia/jobs/51291717 |
so i ask because it's used in ParserCombinator.jl. here's an example grammar: sum = Delayed()
val = S"(" + sum + S")" | PFloat64()
neg = Delayed() # allow multiple negations (eg ---3)
neg.matcher = val | (S"-" + neg > Neg)
mul = S"*" + neg
div = S"/" + neg > Inv
prd = neg + (mul | div)[0:end] |> Prd
add = S"+" + prd
sub = S"-" + prd > Neg
sum.matcher = prd + (add | sub)[0:end] |> Sum
all = sum + Eos() |
Let's not have that discussion on a long-merged-and-dead pull request. |
then please could you reply on the julia-users thread where you previously didn't address it? |
Using
|>
to chain function calls has become popular. There is also dissatisfaction with the use of.>
,>>
, and.>>
for redirecting I/O. This change addresses that by proposing to use|>
only for function calls, and replacing all redirection operators with the idiomx |> redirect(y)
.The introduction of call overloading makes
x |> y
potentially confusing, since it's not clear whethery
is a functor and we wanty(x)
, or we are calling an overload of|>
. For the same reason, call overloading makes a separate|>
operator unnecessary, since if you really wantx |> y
to work you can definecall
fory
.Some examples:
Of course, this generalizes well too, since it's easy to add more options to
redirect
.(ref #5349)