I love the flow of how pipelines read top-down as a series of steps, but
there's something I don't like about it; having to look back at the start
of the pipeline again to see in what variable the result is stored. It's an
uncanny valley; reading functional code top-down is really clear and easy,
but having to jump back up every now and then feels like when developers
extract single-use functions that really should've stayed inline. It's a
readibility issue.
I wish the assignment was at the end of the pipeline instead. Equality
could've worked, but doesn't, since it handles left and right arguments
differently (illegal pattern, otherwise it'd be great to just put the
variable assignment at the end, `= b`).
Here's a macro that kinda simulates how it would work.
defmacro into(a, b) do
{:=, [line: 1], [b, a]}
end
Intended demo-usage:
|> (into b)
I'd prefer something like `|=>` in place of a pipe
a
|> fn1
|> fn2
|=> b
but this is just a macro right now.
What do you think?
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/1b11f727-fd6a-4467-8754-5eb4649c432c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.