If it can, quite some code could shrink. (Edit: it seems it can't. Too bad. See comments below) I'm not talking about making currying possible (it is anyway), I'm talking about making it the default. (Like it is in most static FPLs) That is, (fn (x y) body) <=> (fn (x) (fn (y) body)) and (provided "foo" takes at least 2 arguments) (foo 42) <=> [foo x _] <=> (fn (x) (+ 42 x)) It could eliminate most of the need for the [] reader macro, making the square brackets and the underscore available for something else (we only have (), {}, and [] as delimiters, which is not much). The [] notation is a great idea, but it is quite redundant with currying. If I need to make my partial application on the second argument instead of the first, like in: [- _ 42] I still have an escape route: swapping the arguments: (def swap (f y x) (f x y)) <=> (def swap (f ) (fn (x y) (f x y))) Remember the currying semantics I use here. So, [- _ 42] <=> ((swap -) 42) <=> (swap - 42) ; function application associates to the left Without the unneeded inner parentheses, We end up with three more character, zero more tokens. To sum it up, [+ x _] => (+ x) ; 1 less token [- _ 42] <=> (swap - 42) ; 3 more characters, 0 more tokens If one wonders if currying is incompatible with optional arguments, Ocaml have both, and it works. The fact that optional arguments and the argument list are at the end makes things even easier. To those who are not yet convinced, currying is (with lambdas and closures) the feature which completes the first class citizenship of functions: With lambdas and closures, passing functions as argument and return values was made easy. With currying, the latter is made trivial. |