3 ms·
> worst of all are the optional parenthesis in function calls ?? > let r = some_function x y z in ... There are no parentheses here, and it's not optiona
by toolslive 4y ago
> worst of all are the optional parenthesis in function calls
??
> let r = some_function x y z in ...
There are no parentheses here, and it's not optional.
What you probably are missing is that if `some_function` takes 3 arguments,
then `some_function x y` is a function value that takes 1 parameter (currying).
Btw, iirc, SML doesn't have this: there you only have 1 parameter but it could be a tuple
- raverbashing 4y ago> Note how OCaml is flexible about whether you write the parentheses or not, and whether you write whitespace or not. from here https://cs3110.github.io/textbook/chapters/basics/toplevel.html#functions https://cs3110.github.io/textbook/chapters/basics/toplevel.h...
- toolslive 4y agoisn't that the case in most programming languages ? In essence, if you have an expression exp then (exp) is also an expression. So nothing special about OCaml in that regard. [note, just checked python, php, and js and it is the case]
- raverbashing 4y agoOk so maybe the example is confusing, because it seemed it was talking about function calls (where they are mandatory in the languages you mentioned)
- frou_dh 4y ago> Btw, iirc, SML doesn't have this: there you only have 1 parameter but it could be a tuple Nah, SML does also support automatically curried function definitions, it's just that by convention that feature didn't get used as often. I tried to find out why that was the case a while ago, and stumbled on this explanation: https://www.reddit.com/r/ProgrammingLanguages/comments/jde9xp/advantages_of_currying_in_a_programming_language/g97szvz/ https://www.reddit.com/r/ProgrammingLanguages/comments/jde9x...