An Interest In:
Web News this Week
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
Why I think the dot is not a problem in Elixir
The Elixir community knows that, in Elixir, when you define an anonymous function and assign it to a variable, you have to use a dot (.) to call it:
iex(1)> double = fn x -> x*2 end#Function<44.65746770/1 in :erl_eval.expr/5>iex(2)> double.(3)6iex(3)>
This doesn't happen in Erlang:
1> Double = fun(X) -> X*2 end.#Fun<erl_eval.44.65746770>2> Double(3).63>
You don't have to put a dot between Double
and (3)
in Erlang.
But you have to put a dot at the end of each line.
The late Joe Armstrong, one of the creators of Erlang, wrote in 2013, when he spent "A Week with Elixir," more specifically in the section "Funs have an extra dot in the name":
In school I learned to call functions by writing f(10) not f.(10) this is really a function with a name like Shell.f(10) (its a function defined in the shell) The shell part is implicit so it should just be called f(10).
If you leave it like this expect to spend the next twenty years of your life explaining why. Expect thousands of mails in hundreds of forums.
I believe this didn't happen. One or other person complains here and there, but not "thousands".
Why? My opinion is that Elixir developers usually don't assign an anonymous function to a variable. That's why this is not a big problem. Am I right?
Original Link: https://dev.to/adolfont/why-i-think-the-dot-is-not-a-problem-in-elixir-1nia
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To