5 ms·
The real question is why they do Module.function() and then function.() instead of .function()? It makes no sense to have the dot at the end of an anonymous na
by polack 3y ago
The real question is why they do Module.function() and then function.() instead of .function()?
It makes no sense to have the dot at the end of an anonymous named function.
- sodapopcan 3y ago`function()` is stored inside a `Module`, so we call `Module.function()`. An anonymous function "`()`" is stored inside a `variable`, so we call `variable.()`. It does make some good sense. It's even kinda elegant!
- darraghenright 3y agoI've sometimes wondered if I am the only person who actually likes the syntax :D There's a reason for it, but additionally, I like the fact that it's explicit — I can look at `some_call.()` and specifically know it's an anonymous function.
- sb8244 3y agoI'm a barewords fan, but even I don't understand the hate towards the dot. Honestly, it feels like low level fruit ripe for baiting engagement. Sure it would be cool if it wasn't there, but does it really materially change anything?
- sodapopcan 3y agoI like barewords in Ruby but they don't hold the same value for me in Elixir. In Ruby I was trying to write code in a way where it didn't matter all that much where stuff was coming from. In Elixir I want to know exactly where stuff is coming from and what it is (like how we generally don't `import Enum` or the like). Not to say you shouldn't like barewords! It is nice that Elixir enables that possibility for those who want it!
- sb8244 3y agoI feel this same way now. Although it's been a few years growing on me
- sodapopcan 3y agoI'm repeating myself from another thread but ah well! It has that nice parallel to Erlang too where the calls look distinct: `f()` for function call, `F()` for anonymous function call! All that to say that I agree and I also like the dot syntax :)
- sodapopcan 3y agoOops, it says this in the article. Embarrassing for me :grimace-emoji
- brightball 3y agoWhen it's explained that way, it makes a lot of sense.