--
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-co...@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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-6pChjS%2BfTADa9_1sMow4A5S88azM_FDqKOcxDxNJXakg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4L-Qx2tdNTaNiKkGve0%3Dx1J_7esSJKH68k3zzYURCHGeg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAEmrurpqEtb-9_A1EqdQXkBcWio0w6uwxF_CN2dipj8xt_%2BWcQ%40mail.gmail.com.
def find_foos(string) do
string
|> String.upcase()
|> &Regex.scan(~r/foo/, &1)
end
def
find_foos(string) do
string
|> String.upcase()
|>
do_find_foos()
end
def do_find_foos(str)
Regex.scan(~r/foo/, str)
end
--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/e19a826f-dd41-29fb-4ce0-723e1ef25374%40resilia.nl.
I really want to avoid new syntactical constructs or special casing anonymous functions as I believe it will be more confusing in the long term.
--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/0f96553b-4db8-43f3-9565-b7749526c6d5%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.
1. Can we focus on the pros and cons of what was proposed?
defmodule F do defmacro pipe_to(pipe, {function, _env, args}) when is_atom(function) and is_list(args) do func_arg = quote do: a args = for arg <- args do case arg do {:_, _, _} -> func_arg _ -> arg end end
quote do (fn unquote(func_arg) -> unquote(function)(unquote_splicing(args)) end).(unquote(pipe)) end endend
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) dofun = &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 elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/9ec4915c-436a-300f-7501-e5231e356c36%40resilia.nl.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/JVFGZm58Qo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/83e76b6e-32e1-4d92-8e52-29a218cbba28%40googlegroups.com.
The `Function` module was introduced not long ago as there was no good place to host the functions that are currently in there. Having a function with this particular behavior into the `Function` module seems weird to me. Was having `Pipe` module considered at any point? Examples: `Pipe.to` or `Pipe.into`:
--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/b08a7b47-8a49-4add-a924-be4a50a659a9%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KW%2BvPVeNo7O2%2B5eX1u3eZcZ%3DUHQox%2BHoOXHwit-kLK2g%40mail.gmail.com.