1
2
3OCAML(1) General Commands Manual OCAML(1)
4
5
6
8 ocaml - The Objective Caml interactive toplevel
9
10
12 ocaml [ options ] [ object-files ] [ script-file ]
13
15 The ocaml(1) command is the toplevel system for Objective Caml, that
16 permits interactive use of the Objective Caml system through a read-
17 eval-print loop. In this mode, the system repeatedly reads Caml phrases
18 from the input, then typechecks, compiles and evaluates them, then
19 prints the inferred type and result value, if any. The system prints a
20 # (sharp) prompt before reading each phrase.
21
22 A toplevel phrase can span several lines. It is terminated by ;; (a
23 double-semicolon). The syntax of toplevel phrases is as follows.
24
25 The toplevel system is started by the command ocaml(1). Phrases are
26 read on standard input, results are printed on standard output, errors
27 on standard error. End-of-file on standard input terminates ocaml(1).
28
29 If one or more object-files (ending in .cmo or .cma) are given, they
30 are loaded silently before starting the toplevel.
31
32 If a script-file is given, phrases are read silently from the file,
33 errors printed on standard error. ocaml(1) exits after the execution
34 of the last phrase.
35
36
38 The following command-line options are recognized by ocaml(1).
39
40 -I directory
41 Add the given directory to the list of directories searched for
42 source and compiled files. By default, the current directory is
43 searched first, then the standard library directory. Directories
44 added with -I are searched after the current directory, in the
45 order in which they were given on the command line, but before
46 the standard library directory.
47
48 If the given directory starts with +, it is taken relative to
49 the standard library directory. For instance, -I +labltk adds
50 the subdirectory labltk of the standard library to the search
51 path.
52
53 Directories can also be added to the search path once the
54 toplevel is running with the #directory directive.
55
56 -init file
57 Load the given file instead of the default initialization file.
58 The default file is .ocamlinit in the current directory if it
59 exists, otherwise .ocamlinit in the user's home directory.
60
61 -labels
62 Labels are not ignored in types, labels may be used in applica‐
63 tions, and labelled parameters can be given in any order. This
64 is the default.
65
66 -noassert
67 Do not compile assertion checks. Note that the special form
68 assert false is always compiled because it is typed specially.
69
70 -nolabels
71 Ignore non-optional labels in types. Labels cannot be used in
72 applications, and parameter order becomes strict.
73
74 -noprompt
75 Do not display any prompt when waiting for input.
76
77 -nostdlib
78 Do not include the standard library directory in the list of
79 directories searched for source and compiled files.
80
81 -principal
82 Check information path during type-checking, to make sure that
83 all types are derived in a principal way. When using labelled
84 arguments and/or polymorphic methods, this flag is required to
85 ensure future versions of the compiler will be able to infer
86 types correctly, even if internal algorithms change. All pro‐
87 grams accepted in -principal mode are also accepted in the
88 default mode with equivalent types, but different binary signa‐
89 tures, and this may slow down type checking; yet it is a good
90 idea to use it once before publishing source code.
91
92 -rectypes
93 Allow arbitrary recursive types during type-checking. By
94 default, only recursive types where the recursion goes through
95 an object type are supported.
96
97 -unsafe
98 Turn bound checking off on array and string accesses (the
99 v.(i)ands.[i] constructs). Programs compiled with -unsafe are
100 therefore slightly faster, but unsafe: anything can happen if
101 the program accesses an array or string outside of its bounds.
102
103 -version
104 Print version string and exit.
105
106 -w warning-list
107 Enable or disable warnings according to the argument warning-
108 list. See ocamlc(1) for the syntax of the argument.
109
110 -warn-error warning-list
111 Treat as errors the warnings enabled by the argument warning-
112 list. See ocamlc(1) for the syntax of the argument.
113
114 -help or --help
115 Display a short usage summary and exit.
116
117
119 LC_CTYPE
120 If set to iso_8859_1, accented characters (from the ISO Latin-1
121 character set) in string and character literals are printed as
122 is; otherwise, they are printed as decimal escape sequences.
123
124 TERM When printing error messages, the toplevel system attempts to
125 underline visually the location of the error. It consults the
126 TERM variable to determines the type of output terminal and look
127 up its capabilities in the terminal database.
128
129
131 ocamlc(1), ocamlopt(1), ocamlrun(1).
132 The Objective Caml user's manual, chapter "The toplevel system".
133
134
135
136 OCAML(1)