2 FAQ: how to upgrade from Objective Caml 3.02 to 3.03
6 Q1: When compiling the distribution, I am getting strange linking
7 errors in "otherlibraries".
9 A1: This is probably a problem with dynamic linking. You can disable
10 it with ./configure -no-shared-libs. If you really want to use
11 shared libraries, look in the manual pages of your system for how
12 to get some debugging output from the dynamic linker.
16 Q2: I get a syntax error when I try to compile a program using stream
19 A2: Stream parser now require camlp4. It is included in the
20 distribution, and you just need to use "ocamlc -pp camlp4o" in
21 place of "ocamlc". You can also use it under the toplevel with
24 Q3: I get a warning when I use the syntax "#variant" inside type
27 A3: The new syntax is [< variant], which just a special case of
28 the more general new syntax, which allows type expressions like
29 [ variant1 | variant2] or [> variant]. See the reference manual
34 Q4: I was using labels before, and now I get lots of type errors.
36 A4: The handling of labels changed with 3.03-alpha. The new default
37 is a more flexible version of the commuting label mode, allowing
38 one to omit labels in total applications. There is still a
39 -nolabels mode, but it does not allow non-optional labels in
40 applications (this was unsound).
41 To keep full compatibility with Objective Caml 2, labels were
42 removed from the standard libraries. Some labelized libraries are
43 kept as StdLabels (contains Array, List and String), MoreLabels
44 (contains Hashtbl, Map and Set), and UnixLabels.
45 Note that MoreLabels' status is not yet decided.
47 Q5: Why isn't there a ThreadUnixLabels module ?
49 A5: ThreadUnix is deprecated. It only calls directly the Unix module.
51 Q6: I was using commuting label mode, how can I upgrade ?
53 A6: The new behaviour is compatible with commuting label mode, but
54 standard libraries have no labels. You can add the following
55 lines at the beginning of your files (according to your needs):
58 module Unix = UnixLabels
59 Alternatively, if you already have a common module opened by
60 everybody, you can add these:
63 module Unix = UnixLabels
65 You will then need to remove labels in functions from other modules.
66 This can be automated by using the scrapelabels tool, installed
67 in the Objective Caml library directory, which both removes labels
68 and inserts needed `open' clauses (see -help for details).
69 $CAMLLIB/scrapelabels -keepstd *.ml
71 $CAMLLIB/scrapelabels -keepmore *.ml
72 Note that scrapelabels is not guaranteed to be sound for commuting
73 label programs, since it will just remove labels, and not reorder
76 Q7: I was using a few labels in classic mode, and now I get all these
77 errors. I just want to get rid of all these silly labels.
79 A7: scrapelabels will do it for you.
80 $CAMLLIB/scrapelabels [-all] *.ml
81 $CAMLLIB/scrapelabels -intf *.mli
82 You should specify the -all option only if you are sure that your
83 sources do not contain calls to functions with optional
84 parameters, as those labels would also be removed.
86 Q8: I was using labels in classic mode, and I was actually pretty fond
87 of them. How much more labels will I have to write now ? How can I
88 convert my programs and libraries ?
90 A8: The new default mode is more flexible than the original commuting
91 mode, so that you shouldn't see too much differences when using
92 labeled libraries. Labels are only compulsory in partial
93 applications (including the special case of function with an
94 unknown return type), or if you wrote some of them.
96 On the other hand, for definitions, labels present in the
97 interface must also be present in the implementation.
98 The addlabels tool can help you to do that. Suppose that you have
99 mymod.ml and mymod.mli, where mymod.mli adds some labels. Then
101 $CAMLLIB/addlabels mymod.ml
102 will insert labels from the interface inside the implementation.
103 It also takes care of inserting them in recursive calls, as
104 the return type of the function is not known while typing it.
106 If you used labels from standard libraries, you will also have
107 problems with them. You can proceed as described in A6. Since you
108 used classic mode, you do not need to bother about changed