OCaml Features




# let add5 (x) = (x + 5);;
val add5 : int -> int = <fun>
# let typecrash str = add5("hello");;
Characters 25-32:
  let typecrash str = add5("hello");;
                           ^^^^^^^
This expression has type string but
is here used with type int



Objective Caml is statically typed. Verification of compatibility between the types of formal and actual parameters is carried out at program compilation time. From then on it is not necessary to perform such verification during the execution of the program, which increases its efficiency. Verification of typing also avoids errors introduced by typos or programmer carelessness and contributes to execution safety.

Prev | Next