Login

Caveats

*from OCaml: the bugs so far

No warning about leading zeroes

(* o23.ml *)
let () =
  (* set my perms to u=rwx, g/o nothing *)
  Unix.chmod Sys.argv.(0) 0700
$ ocamlfind ocamlc -linkpkg -package unix o23.ml 
$ ls -ld a.out|cut -d' ' -f1
-rwxr-xr-x.
$ ./a.out 
$ ls -ld a.out|cut -d' ' -f1
--w-rwxr-T.

0700 is decimal 700, not the octal number mapping to binary 111_000_000. Octal 700 is written 0o700.

# let huh = 0700 in huh=700, huh, 0o700, 0b111000000;;
- : bool * int * int * int = (true, 700, 448, 448)

No warning about uncalled unit functions in a sequence

(* o24.ml *)
let trace fn =
  print_endline "START";
  fn ();
  print_endline "END"

let () = trace (fun () -> Printf.printf "Hello %s!\n")
$ ocaml o24.ml 
START
END
$ ocaml -strict-sequence o24.ml 
File "./o24.ml", line 6, characters 26-53:
6 | let () = trace (fun () -> Printf.printf "Hello %s!\n")
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This expression has type string -> unit
       but an expression was expected of type unit
Hint: This function application is partial, maybe some arguments are missing.

That printf, by the %s, is expecting another argument. Merlin helpfully typed the function in the last line as unit -> string -> unit when I couldn't immediately see the problem.

OCaml has tagged integers, 1 bit shorter than you expect

Like typical Common Lisp implementations, and also to give the GC a fast way to distinguish pointers from other data, OCaml int has one less bit available to the programmer than the machine integer has. So on a 64-bit machine,

# max_int, Int64.(div max_int 2L |> to_int) = max_int;;
- : int * bool = (4611686018427387903, true)