455 lines
11 KiB
HTML
455 lines
11 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of OCAML</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>OCAML</H1>
|
|
Section: User Commands (1)<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<P>
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
ocaml - The OCaml interactive toplevel
|
|
<P>
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>ocaml</B>
|
|
|
|
[
|
|
<I>options</I>
|
|
|
|
]
|
|
[
|
|
<I>object-files</I>
|
|
|
|
]
|
|
[
|
|
<I>script-file</I>
|
|
|
|
]
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<P>
|
|
The
|
|
<B><A HREF="/cgi-bin/man/man2html?1+ocaml">ocaml</A></B>(1)
|
|
|
|
command is the toplevel system for OCaml,
|
|
that permits interactive use of the OCaml system through a
|
|
read-eval-print loop. In this mode, the system repeatedly reads OCaml
|
|
phrases from the input, then typechecks, compiles and evaluates
|
|
them, then prints the inferred type and result value, if any. The
|
|
system prints a # (hash) prompt before reading each phrase.
|
|
<P>
|
|
A toplevel phrase can span several lines. It is terminated by ;; (a
|
|
double-semicolon). The syntax of toplevel phrases is as follows.
|
|
<P>
|
|
The toplevel system is started by the command
|
|
<B><A HREF="/cgi-bin/man/man2html?1+ocaml">ocaml</A></B>(1).
|
|
|
|
Phrases are read on standard input, results are printed on standard
|
|
output, errors on standard error. End-of-file on standard input
|
|
terminates
|
|
<B><A HREF="/cgi-bin/man/man2html?1+ocaml">ocaml</A></B>(1).
|
|
|
|
<P>
|
|
If one or more
|
|
<I>object-files</I>
|
|
|
|
(ending in .cmo or .cma) are given, they are loaded silently before
|
|
starting the toplevel.
|
|
<P>
|
|
If a
|
|
<I>script-file</I>
|
|
|
|
is given, phrases are read silently from the file, errors printed on
|
|
standard error.
|
|
<B><A HREF="/cgi-bin/man/man2html?1+ocaml">ocaml</A></B>(1)
|
|
|
|
exits after the execution of the last phrase.
|
|
<P>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
<P>
|
|
The following command-line options are recognized by
|
|
<B><A HREF="/cgi-bin/man/man2html?1+ocaml">ocaml</A></B>(1).
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>-absname</B>
|
|
|
|
<DD>
|
|
Show absolute filenames in error messages.
|
|
<DT id="2"><B>-I</B><I> directory</I>
|
|
|
|
<DD>
|
|
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
|
|
with
|
|
<B>-I</B>
|
|
|
|
are searched after the current directory, in the order in which they
|
|
were given on the command line, but before the standard library
|
|
directory.
|
|
<DT id="3"><DD>
|
|
If the given directory starts with
|
|
<B>+</B>,
|
|
|
|
it is taken relative to the
|
|
standard library directory. For instance,
|
|
<B>-I +compiler-libs</B>
|
|
|
|
adds the subdirectory
|
|
<B>compiler-libs</B>
|
|
|
|
of the standard library to the search path.
|
|
<DT id="4"><DD>
|
|
Directories can also be added to the search path once the toplevel
|
|
is running with the
|
|
<B>#directory</B>
|
|
|
|
directive.
|
|
<DT id="5"><B>-init</B><I> file</I>
|
|
|
|
<DD>
|
|
Load the given file instead of the default initialization file.
|
|
See the "Initialization file" section below.
|
|
<DT id="6"><B>-labels</B>
|
|
|
|
<DD>
|
|
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.
|
|
<DT id="7"><B>-no-app-funct</B>
|
|
|
|
<DD>
|
|
Deactivates the applicative behaviour of functors. With this option,
|
|
each functor application generates new types in its result and
|
|
applying the same functor twice to the same argument yields two
|
|
incompatible structures.
|
|
<DT id="8"><B>-noassert</B>
|
|
|
|
<DD>
|
|
Do not compile assertion checks. Note that the special form
|
|
<B>assert false</B>
|
|
|
|
is always compiled because it is typed specially.
|
|
<DT id="9"><B>-noinit</B>
|
|
|
|
<DD>
|
|
Do not load any initialization file.
|
|
See the "Initialization file" section below.
|
|
<DT id="10"><B>-nolabels</B>
|
|
|
|
<DD>
|
|
Ignore non-optional labels in types. Labels cannot be used in
|
|
applications, and parameter order becomes strict.
|
|
<DT id="11"><B>-noprompt</B>
|
|
|
|
<DD>
|
|
Do not display any prompt when waiting for input.
|
|
<DT id="12"><B>-nopromptcont</B>
|
|
|
|
<DD>
|
|
Do not display the secondary prompt when waiting for continuation lines in
|
|
multi-line inputs. This should be used e.g. when running
|
|
<B><A HREF="/cgi-bin/man/man2html?1+ocaml">ocaml</A></B>(1)
|
|
|
|
in an
|
|
<B><A HREF="/cgi-bin/man/man2html?1+emacs">emacs</A></B>(1)
|
|
|
|
window.
|
|
<DT id="13"><B>-nostdlib</B>
|
|
|
|
<DD>
|
|
Do not include the standard library directory in the list of
|
|
directories searched for source and compiled files.
|
|
<DT id="14"><B>-open</B><I> module</I>
|
|
|
|
<DD>
|
|
Opens the given module before starting the toplevel. If several
|
|
<B>-open</B>
|
|
|
|
options are given, they are processed in order, just as if
|
|
the statements open! module1;; ... open! moduleN;; were input.
|
|
<DT id="15"><B>-ppx</B><I> command</I>
|
|
|
|
<DD>
|
|
After parsing, pipe the abstract syntax tree through the preprocessor
|
|
<I>command</I>.
|
|
|
|
The module
|
|
<B><A HREF="/cgi-bin/man/man2html?3+Ast_mapper">Ast_mapper</A></B>(3)
|
|
|
|
implements the external interface of a preprocessor.
|
|
<DT id="16"><B>-principal</B>
|
|
|
|
<DD>
|
|
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</B>
|
|
|
|
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.
|
|
<DT id="17"><B>-rectypes</B>
|
|
|
|
<DD>
|
|
Allow arbitrary recursive types during type-checking. By default,
|
|
only recursive types where the recursion goes through an object type
|
|
are supported.
|
|
<DT id="18"><B>-safe-string</B>
|
|
|
|
<DD>
|
|
Enforce the separation between types
|
|
<B>string</B> and <B>bytes</B>,
|
|
|
|
thereby making strings read-only. This is the default.
|
|
<DT id="19"><B>-short-paths</B>
|
|
|
|
<DD>
|
|
When a type is visible under several module-paths, use the shortest
|
|
one when printing the type's name in inferred interfaces and error and
|
|
warning messages.
|
|
<DT id="20"><B>-stdin</B>
|
|
|
|
<DD>
|
|
Read the standard input as a script file rather than starting an
|
|
interactive session.
|
|
<DT id="21"><B>-strict-sequence</B>
|
|
|
|
<DD>
|
|
Force the left-hand part of each sequence to have type unit.
|
|
<DT id="22"><B>-unboxed-types</B>
|
|
|
|
<DD>
|
|
When a type is unboxable (i.e. a record with a single argument or a
|
|
concrete datatype with a single constructor of one argument) it will
|
|
be unboxed unless annotated with
|
|
<B>[@@ocaml.boxed]</B>.
|
|
|
|
<DT id="23"><B>-no-unboxed-types</B>
|
|
|
|
<DD>
|
|
When a type is unboxable it will be boxed unless annotated with
|
|
<B>[@@ocaml.unboxed]</B>.
|
|
|
|
This is the default.
|
|
<DT id="24"><B>-unsafe</B>
|
|
|
|
<DD>
|
|
Turn bound checking off on array and string accesses (the
|
|
<B>v.(i)</B>and<B>s.[i]</B>
|
|
|
|
constructs). Programs compiled with
|
|
<B>-unsafe</B>
|
|
|
|
are therefore slightly faster, but unsafe: anything can happen if the program
|
|
accesses an array or string outside of its bounds.
|
|
<DT id="25"><B>-unsafe-string</B>
|
|
|
|
<DD>
|
|
Identify the types
|
|
<B>string</B> and <B>bytes</B>,
|
|
|
|
thereby making strings writable.
|
|
This is intended for compatibility with old source code and should not
|
|
be used with new software.
|
|
<DT id="26"><B>-version</B>
|
|
|
|
<DD>
|
|
Print version string and exit.
|
|
<DT id="27"><B>-vnum</B>
|
|
|
|
<DD>
|
|
Print short version number and exit.
|
|
<DT id="28"><B>-no-version</B>
|
|
|
|
<DD>
|
|
Do not print the version banner at startup.
|
|
<DT id="29"><B>-w</B><I> warning-list</I>
|
|
|
|
<DD>
|
|
Enable or disable warnings according to the argument
|
|
<I>warning-list</I>.
|
|
|
|
See
|
|
<B><A HREF="/cgi-bin/man/man2html?1+ocamlc">ocamlc</A></B>(1)
|
|
|
|
for the syntax of the
|
|
<I>warning-list</I>
|
|
|
|
argument.
|
|
<DT id="30"><B>-warn-error</B><I> warning-list</I>
|
|
|
|
<DD>
|
|
Mark as fatal the warnings described by the argument
|
|
<I>warning-list</I>.
|
|
|
|
Note that a warning is not triggered (and does not trigger an error) if
|
|
it is disabled by the
|
|
<B>-w</B>
|
|
|
|
option. See
|
|
<B><A HREF="/cgi-bin/man/man2html?1+ocamlc">ocamlc</A></B>(1)
|
|
|
|
for the syntax of the
|
|
<I>warning-list</I>
|
|
|
|
argument.
|
|
<DT id="31"><B>-color</B><I> mode</I>
|
|
|
|
<DD>
|
|
Enable or disable colors in compiler messages (especially warnings and errors).
|
|
The following modes are supported:
|
|
<P>
|
|
<B>auto</B>
|
|
|
|
use heuristics to enable colors only if the output supports them (an
|
|
ANSI-compatible tty terminal);
|
|
<P>
|
|
<B>always</B>
|
|
|
|
enable colors unconditionally;
|
|
<P>
|
|
<B>never</B>
|
|
|
|
disable color output.
|
|
<P>
|
|
The default setting is
|
|
<B>auto,</B>
|
|
|
|
and the current heuristic
|
|
checks that the "TERM" environment variable exists and is
|
|
not empty or "dumb", and that isatty(stderr) holds.
|
|
<P>
|
|
The environment variable "OCAML_COLOR" is considered if -color is not
|
|
provided. Its values are auto/always/never as above.
|
|
<P>
|
|
<DT id="32"><B>-error-style</B><I> mode</I>
|
|
|
|
<DD>
|
|
Control the way error messages and warnings are printed.
|
|
The following modes are supported:
|
|
<P>
|
|
<B>short</B>
|
|
|
|
only print the error and its location;
|
|
<P>
|
|
<B>contextual</B>
|
|
|
|
like "short", but also display the source code snippet corresponding
|
|
to the location of the error.
|
|
<P>
|
|
The default setting is
|
|
<B>contextual.</B>
|
|
|
|
<P>
|
|
The environment variable "OCAML_ERROR_STYLE" is considered if
|
|
-error-style is not provided. Its values are short/contextual as
|
|
above.
|
|
<P>
|
|
<DT id="33"><B>-warn-help</B>
|
|
|
|
<DD>
|
|
Show the description of all available warning numbers.
|
|
<DT id="34"><B>-</B><I> file</I>
|
|
|
|
<DD>
|
|
Use
|
|
<I>file</I>
|
|
|
|
as a script file name, even when it starts with a hyphen (-).
|
|
<DT id="35"><B>-help</B> or<B> --help</B>
|
|
|
|
<DD>
|
|
Display a short usage summary and exit.
|
|
<P>
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>INITIALIZATION FILE</H2>
|
|
|
|
<P>
|
|
When
|
|
<B><A HREF="/cgi-bin/man/man2html?1+ocaml">ocaml</A></B>(1)
|
|
|
|
is invoked, it will read phrases from an initialization file before
|
|
giving control to the user. The default file is
|
|
<B>.ocamlinit</B>
|
|
|
|
in the current directory if it exists, otherwise
|
|
<B>.ocamlinit</B>
|
|
|
|
in the user's home directory. You can specify a different initialization file
|
|
by using the
|
|
<B>-init</B><I> file</I>
|
|
|
|
option, and disable initialization files by using the
|
|
<B>-noinit</B>
|
|
|
|
option.
|
|
<P>
|
|
Note that you can also use the
|
|
<B>#use</B>
|
|
|
|
directive to read phrases from a file.
|
|
<P>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>ENVIRONMENT VARIABLES</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="36"><B>OCAMLTOP_UTF_8</B>
|
|
|
|
<DD>
|
|
When printing string values, non-ascii bytes (>0x7E) are printed as
|
|
decimal escape sequence if
|
|
<B>OCAMLTOP_UTF_8</B>
|
|
|
|
is set to false. Otherwise they are printed unescaped.
|
|
<DT id="37"><B>TERM</B>
|
|
|
|
<DD>
|
|
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.
|
|
<P>
|
|
</DL>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+ocamlc">ocamlc</A></B>(1),<B> <A HREF="/cgi-bin/man/man2html?1+ocamlopt">ocamlopt</A></B>(1),<B> <A HREF="/cgi-bin/man/man2html?1+ocamlrun">ocamlrun</A></B>(1).
|
|
|
|
<BR>
|
|
|
|
<I>The OCaml user's manual</I>,
|
|
|
|
chapter "The toplevel system".
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="38"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="39"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="40"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="41"><A HREF="#lbAE">OPTIONS</A><DD>
|
|
<DT id="42"><A HREF="#lbAF">INITIALIZATION FILE</A><DD>
|
|
<DT id="43"><A HREF="#lbAG">ENVIRONMENT VARIABLES</A><DD>
|
|
<DT id="44"><A HREF="#lbAH">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:20 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|