| Re: Pipe operator Their argument for replacing the pipe operator is to do this instead: foo(X) -> final_function(maybe_function(X)).
into this:foo(X) -> Maybe = maybe_function(X),
final_function(Maybe).
instead of this:x |> maybe_function() |> final_function() Their exact words: Spelling things out so pedantically makes code dead-simple & clear. Yes, there is a tad more code, but you will also note that nothing is hiding. Un-nesting simply dumbs things down. Now, who wouldn’t want that after hours of squinting at a screen? People love to trot out the "It's more explicit, its a bit more code but isn't it more READABLE" argument about everything. I've heard this argument used to oppose information hiding while refactoring functions to be smaller. And I would argue that "readable" is subjective, and that their argument is extremely weak. I love the pipeline operator and think it should be standard in every language. Also, his "Maybe" variable becomes a pain to maintain when you have a pipeline of multiple functions. edit: for bad formatting |
But for someone who is used to languages where these constructs (or list comprehensions) are idiomatic, they are perfectly clear and explicit, and using a for loop instead adds complexity.