On 13-08-2019 11:03, José Valim wrote:

>
> [...] if I have experience with other functional programming
> languages, I would expect to be able to write this:
>
> def find_foos(string) do
>   fun = &Regex.scan(~r/foo/, &1)
>   string
>   |> String.upcase()
>   |> fun
> end
>
> But that won't work, it has to be "fun.()". So I think we need to work
> consistently with calls. Allowing something that is not a call will be
> confusing.

This is a good counter-argument. 👍Maybe it is possible to super-charge
the |&|-macro to even work in those cases, but it might become too
abuse-enabling if we do.

Playing devil’s advocate a little, however: what would you expect to
happen when someone does the same thing with |Function.pipe_to| (or
whatever name is decided upon)?:

|def find_foos(string) do fun = Function.pipe_to(&Regex.scan(~r/foo/,
&1)) string |> String.upcase() |> fun end |

~Marten/Qqwy

​

-- 
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/9ec4915c-436a-300f-7501-e5231e356c36%40resilia.nl.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to