In most uses of functional-style piping I’ve seen in Julia, it seems that a lot of people don’t realize that
|> has precedence over
data |> x -> f(x) |> g
data |> x -> g(f(x))
data |> (x -> f(x)) |> g
In most cases, it doesn’t really matter because it works out the same either way, but it can do some unexpected things with broadcasted piping:
julia> (1, 2) .|> x -> x^2 |> sum (1, 4) julia> (1, 2) .|> (x -> x^2) |> sum 5
I bring this up because I see this mistake everywhere. I’ve seen it on questions posted here. I’ve seen it in blog posts from pretty experienced data scientists. I even saw it in a tutorial this morning.
This seems like one of those “if everyone is walking over the same path on a lawn, maybe we should pave a walkway over that path” situations. I can only see this type of usage increasing as functional programming styles are becoming more popular. Of course, it could be mentioned in up front the docs that it is a good practice to use parentheses in this case to avoid ambiguity, but there are only so many things we can put up front in the docs.