2008-09-11 09:34:57 -07:00
|
|
|
\" $Id$
|
|
|
|
|
1996-05-10 06:27:26 -07:00
|
|
|
.TH OCAML 1
|
1995-11-02 08:54:37 -08:00
|
|
|
|
|
|
|
.SH NAME
|
1996-04-30 07:53:58 -07:00
|
|
|
ocaml \- The Objective Caml interactive toplevel
|
1995-11-02 08:54:37 -08:00
|
|
|
|
|
|
|
.SH SYNOPSIS
|
1996-04-30 07:53:58 -07:00
|
|
|
.B ocaml
|
1995-11-02 08:54:37 -08:00
|
|
|
[
|
2008-09-11 09:16:27 -07:00
|
|
|
.I options
|
1995-11-02 08:54:37 -08:00
|
|
|
]
|
2000-02-06 19:29:29 -08:00
|
|
|
[
|
2002-02-08 02:16:10 -08:00
|
|
|
.I object-files
|
|
|
|
]
|
|
|
|
[
|
2000-02-06 19:29:29 -08:00
|
|
|
.I script-file
|
|
|
|
]
|
1995-11-02 08:54:37 -08:00
|
|
|
.SH DESCRIPTION
|
|
|
|
|
|
|
|
The
|
1996-04-30 07:53:58 -07:00
|
|
|
.BR ocaml (1)
|
|
|
|
command is the toplevel system for Objective Caml,
|
|
|
|
that permits interactive use of the Objective Caml system through a
|
1995-11-02 08:54:37 -08:00
|
|
|
read-eval-print loop. In this mode, the system repeatedly reads Caml
|
2007-10-08 07:19:34 -07:00
|
|
|
phrases from the input, then typechecks, compiles and evaluates
|
1995-11-02 08:54:37 -08:00
|
|
|
them, then prints the inferred type and result value, if any. The
|
|
|
|
system prints a # (sharp) prompt before reading each phrase.
|
|
|
|
|
|
|
|
A toplevel phrase can span several lines. It is terminated by ;; (a
|
|
|
|
double-semicolon). The syntax of toplevel phrases is as follows.
|
|
|
|
|
2008-09-11 09:16:27 -07:00
|
|
|
The toplevel system is started by the command
|
1996-04-30 07:53:58 -07:00
|
|
|
.BR ocaml (1).
|
1995-11-02 08:54:37 -08:00
|
|
|
Phrases are read on standard input, results are printed on standard
|
|
|
|
output, errors on standard error. End-of-file on standard input
|
|
|
|
terminates
|
1996-04-30 07:53:58 -07:00
|
|
|
.BR ocaml (1).
|
1995-11-02 08:54:37 -08:00
|
|
|
|
2002-02-08 02:16:10 -08:00
|
|
|
If one or more
|
|
|
|
.I object-files
|
2008-09-15 07:05:30 -07:00
|
|
|
(ending in .cmo or .cma) are given, they are loaded silently before
|
|
|
|
starting the toplevel.
|
2002-02-08 02:16:10 -08:00
|
|
|
|
2000-02-06 19:29:29 -08:00
|
|
|
If a
|
|
|
|
.I script-file
|
|
|
|
is given, phrases are read silently from the file, errors printed on
|
|
|
|
standard error.
|
|
|
|
.BR ocaml (1)
|
|
|
|
exits after the execution of the last phrase.
|
|
|
|
|
1995-11-02 08:54:37 -08:00
|
|
|
.SH OPTIONS
|
|
|
|
|
|
|
|
The following command-line options are recognized by
|
1996-04-30 07:53:58 -07:00
|
|
|
.BR ocaml (1).
|
1995-11-02 08:54:37 -08:00
|
|
|
.TP
|
2009-05-20 04:52:42 -07:00
|
|
|
.BI \-I \ directory
|
1995-11-02 08:54:37 -08:00
|
|
|
Add the given directory to the list of directories searched for
|
|
|
|
source and compiled files. By default, the current directory is
|
|
|
|
searched first, then the standard library directory. Directories added
|
2008-09-11 09:16:27 -07:00
|
|
|
with
|
1995-11-02 08:54:37 -08:00
|
|
|
.B \-I
|
|
|
|
are searched after the current directory, in the order in which they
|
|
|
|
were given on the command line, but before the standard library
|
|
|
|
directory.
|
2008-09-11 09:16:27 -07:00
|
|
|
.IP
|
|
|
|
If the given directory starts with
|
|
|
|
.BR + ,
|
|
|
|
it is taken relative to the
|
|
|
|
standard library directory. For instance,
|
2008-09-15 07:05:30 -07:00
|
|
|
.B \-I\ +labltk
|
2008-09-11 09:16:27 -07:00
|
|
|
adds the subdirectory
|
|
|
|
.B labltk
|
|
|
|
of the standard library to the search path.
|
|
|
|
.IP
|
|
|
|
Directories can also be added to the search path once the toplevel
|
|
|
|
is running with the
|
|
|
|
.B #directory
|
|
|
|
directive.
|
|
|
|
.TP
|
|
|
|
.BI \-init \ file
|
|
|
|
Load the given file instead of the default initialization file.
|
|
|
|
The default file is
|
|
|
|
.B .ocamlinit
|
|
|
|
in the current directory if it exists, otherwise
|
|
|
|
.B .ocamlinit
|
|
|
|
in the user's home directory.
|
|
|
|
.TP
|
|
|
|
.B \-labels
|
|
|
|
Labels are not ignored in types, labels may be used in applications,
|
|
|
|
and labelled parameters can be given in any order. This is the default.
|
|
|
|
.TP
|
|
|
|
.B \-noassert
|
|
|
|
Do not compile assertion checks. Note that the special form
|
2008-09-15 07:05:30 -07:00
|
|
|
.B assert\ false
|
2008-09-11 09:16:27 -07:00
|
|
|
is always compiled because it is typed specially.
|
|
|
|
.TP
|
|
|
|
.B \-nolabels
|
|
|
|
Ignore non-optional labels in types. Labels cannot be used in
|
|
|
|
applications, and parameter order becomes strict.
|
|
|
|
.TP
|
|
|
|
.B \-noprompt
|
|
|
|
Do not display any prompt when waiting for input.
|
|
|
|
.TP
|
|
|
|
.B \-nostdlib
|
|
|
|
Do not include the standard library directory in the list of
|
|
|
|
directories searched for source and compiled files.
|
|
|
|
.TP
|
|
|
|
.B \-principal
|
|
|
|
Check information path during type-checking, to make sure that all
|
|
|
|
types are derived in a principal way. When using labelled arguments
|
|
|
|
and/or polymorphic methods, this flag is required to ensure future
|
|
|
|
versions of the compiler will be able to infer types correctly, even
|
|
|
|
if internal algorithms change.
|
|
|
|
All programs accepted in
|
|
|
|
.B \-principal
|
|
|
|
mode are also accepted in the
|
|
|
|
default mode with equivalent types, but different binary signatures,
|
|
|
|
and this may slow down type checking; yet it is a good idea to
|
|
|
|
use it once before publishing source code.
|
|
|
|
.TP
|
|
|
|
.B \-rectypes
|
|
|
|
Allow arbitrary recursive types during type-checking. By default,
|
|
|
|
only recursive types where the recursion goes through an object type
|
|
|
|
are supported.
|
1995-11-02 08:54:37 -08:00
|
|
|
.TP
|
|
|
|
.B \-unsafe
|
2008-09-11 09:16:27 -07:00
|
|
|
Turn bound checking off on array and string accesses (the
|
|
|
|
.BR v.(i) and s.[i]
|
|
|
|
constructs). Programs compiled with
|
1995-11-02 08:54:37 -08:00
|
|
|
.B \-unsafe
|
|
|
|
are therefore slightly faster, but unsafe: anything can happen if the program
|
|
|
|
accesses an array or string outside of its bounds.
|
2008-09-11 09:16:27 -07:00
|
|
|
.TP
|
|
|
|
.B \-version
|
|
|
|
Print version string and exit.
|
|
|
|
.TP
|
2010-05-20 07:06:29 -07:00
|
|
|
.B \-vnum
|
|
|
|
Print short version number and exit.
|
|
|
|
.TP
|
2008-09-11 09:16:27 -07:00
|
|
|
.BI \-w \ warning-list
|
|
|
|
Enable or disable warnings according to the argument
|
|
|
|
.IR warning-list .
|
|
|
|
See
|
|
|
|
.BR ocamlc (1)
|
2009-11-02 04:17:49 -08:00
|
|
|
for the syntax of the
|
|
|
|
.I warning\-list
|
|
|
|
argument.
|
2008-09-11 09:16:27 -07:00
|
|
|
.TP
|
|
|
|
.BI \-warn-error \ warning-list
|
2009-11-02 04:17:49 -08:00
|
|
|
Treat as errors the warnings described by the argument
|
|
|
|
.IR warning\-list .
|
|
|
|
Note that a warning is not triggered (and not treated as error) if
|
|
|
|
it is disabled by the
|
|
|
|
.B \-w
|
|
|
|
option. See
|
2008-09-11 09:16:27 -07:00
|
|
|
.BR ocamlc (1)
|
2009-11-02 04:17:49 -08:00
|
|
|
for the syntax of the
|
|
|
|
.I warning\-list
|
|
|
|
argument.
|
2008-09-11 09:16:27 -07:00
|
|
|
.TP
|
|
|
|
.BR \-help \ or \ \-\-help
|
2008-09-15 07:05:30 -07:00
|
|
|
Display a short usage summary and exit.
|
1995-11-02 08:54:37 -08:00
|
|
|
|
|
|
|
.SH ENVIRONMENT VARIABLES
|
|
|
|
.TP
|
|
|
|
.B LC_CTYPE
|
|
|
|
If set to iso_8859_1, accented characters (from the
|
|
|
|
ISO Latin-1 character set) in string and character literals are
|
|
|
|
printed as is; otherwise, they are printed as decimal escape sequences.
|
|
|
|
.TP
|
|
|
|
.B TERM
|
|
|
|
When printing error messages, the toplevel system
|
|
|
|
attempts to underline visually the location of the error. It
|
|
|
|
consults the TERM variable to determines the type of output terminal
|
|
|
|
and look up its capabilities in the terminal database.
|
|
|
|
|
|
|
|
.SH SEE ALSO
|
2008-09-11 09:16:27 -07:00
|
|
|
.BR ocamlc (1), \ ocamlopt (1), \ ocamlrun (1).
|
1995-11-02 08:54:37 -08:00
|
|
|
.br
|
2008-09-11 09:16:27 -07:00
|
|
|
.IR The\ Objective\ Caml\ user's\ manual ,
|
1995-11-02 08:54:37 -08:00
|
|
|
chapter "The toplevel system".
|