Skip to content

Grammar inconsistencies

def-lkb edited this page Mar 30, 2014 · 9 revisions

Document known differences between OCaml and Camlp4. Merlin will follow OCaml syntax.

0-uple

# type t = ()

Accepted by ocaml.
Rejected by camlp4.

"()" in an expression context is quite ambiguous after such definitions.

functions in labelled arguments

# let f x = f ~f:fun x -> x;;

Rejected by ocaml.
Accepted by camlp4.

variant extension

# type t = [variants];;

Rejected by ocaml.
Accepted by camlp4.

type annotations on bindings

# let _ : type = value;;

Rejected by ocaml.
Accepted by camlp4.

# let (_ : type) = value;;
# let _id : type = value;;

Accepted by both ocaml and camlp4.

infix operators

# let ( :=> ) = value;;

Rejected by ocaml.
Accepted by camlp4.

precedence of 'if' in rhs of (^)

# "" ^ if true then (); "";;

Rejected by ocaml.
Accepted by camlp4.