4 ms·
Indeed, but leaving out the parens makes more work for humans. What does `a b c` mean? `a(b)(c)`? `a(b(c))`? If the only thing that is gained by leaving out
by stuartaxelowen 10y ago
Indeed, but leaving out the parens makes more work for humans. What does `a b c` mean? `a(b)(c)`? `a(b(c))`? If the only thing that is gained by leaving out the parens is brevity, I don't think its worth it.
- reycharles 10y agoIt would be `(a(b))(c)`. Interestingly, you're already leaving out parens for brevity.
- deno 10y agoBut it’s not `a b c`. Rather it’s something like `verb noun noun`. Which is much less ambiguous. In a language with currying semantics [(((a(b))(c))(d)] the only logical explicit syntax sugar would be LISP-like, so (v n n), (v (v2 n)). That’s imo way worse — you end up with lots of useless junk)))))))) in anything non-trivial.
- stuartaxelowen 10y agoWhat about `verb noun verb noun`? Is the second verb a parameter or is it being invoked on the noun?
- thedufer 10y agoIt's a parameter. The rule isn't complicated - functions are left-associative. That's all you have to remember.
- evincarofautumn 10y agoIt’s no different than having to know the associativity of an operator. Does “a - b - c” mean “(a - b) - c” or “a - (b - c)”? The former, for no reason other than a long history of convention. Same goes for function application. And you could make the same argument about languages that require parentheses for function calls: what does “a(b)(c)” mean? “(a(b))(c)” or “a((b)(c))”? What’s gained is that the syntax mirrors the semantics. If you have a function “f : int -> bool -> int”, then “f 5” has type “bool -> int” and “f 5 true” has type “int”. It’s not like in Forth where you can’t tell from the syntax how many arguments a function takes. That said, I do think right-associative function application may be more intuitive—I like having it in Perl, for example.
- eru 10y agoYou get right-associative function application (in Haskell) by putting $ in between your functions. (And if you are using composition instead, it associates in both directions.)
- rixed 10y agoMore work for humans used to something else. At this point it's worth reminding that ML syntax was originally designed to make programs more palatable to maths students...