-
Notifications
You must be signed in to change notification settings - Fork 233
Grammar inconsistencies
def-lkb edited this page Oct 13, 2014
·
9 revisions
Document known differences between OCaml and Camlp4. Merlin will follow OCaml syntax.
# type t = ()
Accepted by ocaml.
Rejected by camlp4.
"()" in an expression context is quite ambiguous after such definitions.
# let f x = f ~f:fun x -> x;;
Rejected by ocaml.
Accepted by camlp4.
# type t = [variants];;
Rejected by ocaml.
Accepted by camlp4.
# let _ : type = value;;
Rejected by ocaml.
Accepted by camlp4.
# let (_ : type) = value;;
# let _id : type = value;;
Accepted by both ocaml and camlp4.
# let ( :=> ) = value;;
Rejected by ocaml.
Accepted by camlp4.
# "" ^ if true then (); "";;
Rejected by ocaml.
Accepted by camlp4.
# List.(1;2)
Accepted by ocaml.
Rejected by camlp4.
Spotted by obad.
# let (>>>) = (+);; 4; >>> 5;;
Accepted by camlp4 (evaluates to 9).
Rejected by ocaml.
But if we use (+) directly…
# 4; + 5;;
Warning 10: this expression should have type unit.
- : int = 5
# ignore 4; + 5;;
- : int = 5
# #camlp4o;;
# 4; + 5;;
… … (* just wait *)
^C
# ignore 4; + 5;;
… … (* just wait *)
^C
And with utop!
utop # 4; + 5;;
- : int = 9
utop # ignore 4; + 5;;
^^^^^^^^
Error: This expression has type unit but an expression was expected of type int
utop # 4; + 5; + 6;;
… … (* just wait *)
^C
WTF