LOL just got a “popular link” badge for Put The Pipe Down
I know I’m an old fuddy duddy but if I remember my after school special lessons correctly: hitting the pipe once in a while, or even often, is a recipe for a good time had by all! But don’t overdo it there, eh (I’m also Canadian… where we didn’t have after school specials so… whatever)
Like my grandma used to say: “Just write code any ol’ fool can understand so we can make some money and get back to piping.”
Because those are local to the pipe, they aren’t binding values.
This inverts the normal order of binding where the thing being bound is normally on the LHS and now it’s on the RHS. The bit where binding a value interrupts a pipe is a Good Thing. You want that visual cue to say “this value has been shadowed or set”
If you go back and read discussions leading up to the introduction of then, it was a compromise instead of a positional pipe operator—to paraphrase Calvin and Hobbes: “Nobody likes a good compromise.” As for tap, this lets you “put side-effects in a pipeline.” () This has some uses in debugging but otherwise goes against the FP spirit of making side-effects stand out.
It should go without saying that this is all subjective, but dealing with “creative” pipelines in production code makes me crazy.
First come the headache of choosing names (same with assign_to, agree).
Then come the headache if some step must be removed or reordered.
With intermediary variables, all names must be rewritten.
With pipes, it’s just a matter of commenting or moving lines.
I’m not sure I would ever use this but as someone who uses then/2 like a madman I like the look of this.
The inline capture is easily my favorite part. Is it a good idea? I don’t actually see a problem with this at all expect that it’s “weird.” If you’re expecting it and understand it though? It’s not hard to understand.
Are you motivating just regular pipes or are you motivating the OPs library? Cause the arguments you’re making only really apply to regular pipes and yes, that’s why they are great.