4 ms·
Thanks for the feedback. The ~ is a substitute for :, which is used in other languages for optional type annotations. You're right about removing ~ altogether,
by artagnon 11y ago
Thanks for the feedback. The ~ is a substitute for :, which is used in other languages for optional type annotations. You're right about removing ~ altogether, Go style. ~Function(Int -> Int -> Int) is a function which takes two integers, and returns one. I've mixed in some Haskell syntax there. And yes, return type is inferred.
There are two reasons for there not being explanations in the README:
1. I foolishly thought it would be obvious.
2. I wanted to focus on the implementation, not the language itself.
In any case, I've added them now, thanks.
- phamilton 11y agoI think the bigger point of feedback is that anonymous function signatures are drastically different from defined function signatures.
- pmontra 11y agoThanks to everybody for all these explanations! I understand the logic of the syntax now. A nice thing with Elixir is that it lures OO developers like me into the realm of functional languages with a familiar syntax. Int -> Int is not familiar to me. I could guess what it is but then I also see an Int, Int and feel a little puzzled. If one of the goals of this language is to "convert" OO developers maybe you should consider a syntax they are fully familiar with. You could make long time functional developers feel not at home though. Maybe it's a trade-off that's impossible to avoid. It's your call.
- Kabie 11y agoWhy `~Function(Int -> Int -> Int)` instead of `~Int -> Int -> Int`?