Hi everyone,

With the addition of Function.identity/1, I would like to propose another
function to the Function module: pipe_to/2.

The idea is that instead of:

"foo
|> String.upcase()
|> (&Regex.scan(~r/foo/, &1)).()

One can do:

"foo
|> String.upcase()
|> Function.pipe_to(&Regex.scan(~r/foo/, &1))

Or if you import it before:

"foo
|> String.upcase()
|> pipe_to(&Regex.scan(~r/foo/, &1))

While I wouldn't write the "pipe to anonymous" code, I have seen enough
code in the wild that uses it that having a more readable (albeit more
verbose) approach in the language sounds reasonable to me. The
implementation can be inlined by the compiler to avoid the extra dispatch
cost.

What are your thoughts? If you "pipe to anonymous functions" in your code
today, would you prefer to use the new function? Yes/no? Why?

Thank you,

*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

-- 
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 elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4L-4zcvLOnOFSFdnmk0foBJcu94QjrAv9-_QDySN%2BN9bg%40mail.gmail.com.

Reply via email to