
The standard - symbol is used for both negation and subtraction.

Having a unified mechanism for top-level and local bindings leads to less duplication of functionality, and let.in.end seems empirically to lead to clearer error messages. In practice, this approach leads to some very confusing error messages, since the compiler is less able to predict what grouping you really intended. Let rec fact x = if x = 0 then 1 else x * fact (x - 1) inįun fact x = if x = 0 then 1 else x * fact (x - 1) Let rec fact x = if x = 0 then 1 else x * fact (x - 1) Syntactic class of declarations and let.in.end construct for binding them Separate top-level let and let expressions

More flexibility can't hurt if you're careful, right? In actuality, most SML programmers with opinions would prefer the OCaml convention. It also eases the tasks of text editor syntax highlighters, making it easy to distinguish between module and variable names by color, for example. This convention stops a very nasty class of pattern matching bugs involving confusion between variables and variant constructors. | b => 1 (* This case is signaled as redundant. *)Ī' => 0 (* a' is processed as a variable. These operations receive no special treatment.Īrr.(2) 0 (* A' is signaled as an unbound constructor. Special syntactic sugar is defined for array and string accesses. See this syntax comparison for more details.

This page isn't meant to be a complete comparison, but rather to highlight differences that might lead to choosing one language over the other.įor many of the points below, there is a clear distinction between the languages as to which is more "practical" in that design decision and which is more mathematically pure, concerned with formal properties of the language, or otherwise research-oriented. The comparison includes language design and current tool availability, as well as further social factors. This page compares point-by-point the Objective Caml (OCaml) and Standard ML (SML) programming languages, the two main representatives of the ML programming language family.
