Closed syamilmj closed 5 years ago
In your pipes example and the one you link to for
is only further indented by one space instead of two. Does that seem odd to anyone else?
The pipe operator is not the nicest player when it comes to indentation based on factor 2, since it leads to 3 spaces in front of the statements.
123↓
|> Foobar
not working, if "aligned" to above statement
(3 spaces vs. 2 or 4 spaces)
|> sorry
123↓
|> Foobar
not working, because we are off by 1 to above
and are actually introducing 4 space intendation
|> sorry
How do I avoid such mess? In multiline pipes with multiline functions I always extract the functions, because they already distract the visual flow for the pipeline.
So personally I don't even care so much, if there was a guideline for multiline pipelines with necessary indentation, because I have the feeling that such pattern is already a bad one (like a code smell). But again, this is just my opinion.
Multiline pipeline syntax should now look like:
File.stream!("path/to/some/file", read_ahead: 100_000)
|> test()
|> test(fn line ->
for word <- String.split(" "), do: {word, 1}
end)
Consider the codes below:
Notice the pattern in this bit:
for
is only indented by two spaces, andend)
is indented on the line asFlow
I have seen many different ways on how they were written, but this seems to be cleanest way.
Ref: http://elixir-lang.org/blog/2016/07/14/announcing-genstage/