Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



`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!


I'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.


I'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?


I 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!


I feel this same way now. Although it's been a few years growing on me


I'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 :)


Oops, it says this in the article. Embarrassing for me :grimace-emoji


When it's explained that way, it makes a lot of sense.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: