I may be wrong, but I have a vague feeling that it is the other way around: the shorthand is not function
, but fun
. In other words, function
is the basic construction: “function of one argument defined by pattern matching” (remember that in Lambda calculus, all functions have exactly one argument), while fun x y z -> e
is a shorthand for function x -> function y -> function z -> e
.
In Caml Light (the predecessor of OCaml), the fun
keyword could take multiple patterns (like OCaml’s function
) as well as multiple arguments (like OCaml’s fun
), but this introduced an ambiguity that required inserting parentheses around certain patterns. In the case of a single argument Caml Light also had function
(like today’s OCaml), which did not suffer from this ambiguity. Since this issue with the extra parentheses was a bit bothersome, perhaps it was decided not to allow multiple patterns in the fun
construct, and instead fall back on fun
+ match
in that case.
@xavierleroy may be able to shed more light on this question.
Cheers,
Nicolas