3 ms·
F# and all ML derivatives are an aberration because they use juxtaposition to denote function calls. That eliminates a lot of parens but personally I find the
by lisper 10y ago
F# and all ML derivatives are an aberration because they use juxtaposition to denote function calls. That eliminates a lot of parens but personally I find the result less readable.
But compare to, say, C where no one complains about the parens:
int fact(int n) {
if (n==0) {
return 1
} else {
return n*fact(n-1);
}
}
That's six pairs of parens. The only reason it's not more is because some function calls in C are disguised as operators, and those just happen to be the functions that factorial uses. If we wanted a semantically equivalent function that handled bignums you'd have to write:
bignum fact(bignum n) {
if (bignum_is_zero(n)) {
return n;
else {
return bignum_multiply(n, fact(bignum_subtract_1(n)));
}
}
Now you've got nine parens. But still no one complains about C because of that.
- brianberns 10y agoOnly if you assume that curly braces function as parens in C, which isn't true.
- lisper 10y agoIt's not an assumption, it's a fact. Curly braces serve the same function in C as (some of the) parens do in Lisp.
- chriswarbo 10y ago> F# and all ML derivatives are an aberration because they use juxtaposition to denote function calls. That eliminates a lot of parens but personally I find the result less readable. It makes a lot of sense when all functions are curried. Parenthesised function calls treat all of these as different things: f(a, b, c, d) f(a, b, c)(d) f(a, b)(c, d) f(a, b)(c)(d) f(a)(b, c, d) f(a)(b, c)(d) f(a)(b)(c, d) f(a)(b)(c)(d) If functions aren't curried, then these all mean different things. When functions are curried, all of these have the same semantics (call `f` with `a`, call the result with `b`, call that result with `c` and call that result with `d`); ML's juxtaposition syntax makes these semantically-identical expressions syntactically-identical too: f a b c d
- lisper 10y agoYou can curry in Lisp too, and if you do you can get rid of all but one of the unnecessary parens as well. (curry f a b c d)