Here is a summary of the changes, to help you upgrade.
(This is not in the OCaml Changelog, since 2.99 was only a beta)
There are also tools to help you, presented at the end of this note.
label: -> ~label:
:label -> ~label
(label:x : type)-> ~label:(x : type)
(:label : type) -> ~(label : type)
?label: -> ?label: (unchanged)
?:label -> ?label
?(label:x = v) -> ?label:(x = v)
?(:label = v) -> ?(label = v)
Notice that you cannot use keywords as labels anymore.
Also, for OLabl programs, the syntax for default values changed:
?label:x [< v >] -> ?label:(x = v)
Semantics of optional parameters were changed between OLabl
and OCaml 2.99. See the tutorial for the new semantics.
[`A int | `B bool] -> [`A of int | `B of bool]
E.g. List.nth : 'a list -> pos:int -> 'a
became List.nth : 'a list -> int -> 'a
In practice, most functions of two arguments were removed their
labels.
fun: -> f:
pred: -> f:
end: -> stop:
to: -> (no label)
key:,pos:,len:,size: -> often omitted
To convert all files in a directory, just type:
% ocaml299to3 *.ml
For all modified files, the orignal is kept as file.bak.
Quoting Daniel de Raglaudre, here is how to use it:
To compile with the 2.99 syntax, use
ocamlc -pp "camlp4o pa_olabl.cmo"
To switch the toplevel syntax to 2.99,
ocaml -I `camlp4 -where`
# #load "camlp4o.cma";; (* Camlp4 parses *)
# #load "pa_olabl.cmo";; (* switch parser to 2.99 *)
To create a toplevel parsing the 2.99 syntax,
ocamlmktop -o olabl -I `camlp4 -where` gramlib.cma \
camlp4_top.cma pa_olabl.cmo