1105 lines
13 KiB
HTML
1105 lines
13 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Stdlib.Sys</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Stdlib.Sys</H1>
|
|
Section: OCaml library (3o)<BR>Updated: 2020-01-30<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Stdlib.Sys - no description
|
|
<A NAME="lbAC"> </A>
|
|
<H2>Module</H2>
|
|
|
|
Module Stdlib.Sys
|
|
<A NAME="lbAD"> </A>
|
|
<H2>Documentation</H2>
|
|
|
|
<P>
|
|
Module
|
|
<B>Sys</B>
|
|
|
|
<BR> :
|
|
<B>(module Stdlib__sys)</B>
|
|
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val argv </I>
|
|
|
|
:
|
|
<B>string array</B>
|
|
|
|
<P>
|
|
The command line arguments given to the process.
|
|
The first element is the command name used to invoke the program.
|
|
The following elements are the command-line arguments
|
|
given to the program.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val executable_name </I>
|
|
|
|
:
|
|
<B>string</B>
|
|
|
|
<P>
|
|
The name of the file containing the executable currently running.
|
|
This name may be absolute or relative to the current directory, depending
|
|
on the platform and whether the program was compiled to bytecode or a native
|
|
executable.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val file_exists </I>
|
|
|
|
:
|
|
<B>string -> bool</B>
|
|
|
|
<P>
|
|
Test if a file with the given name exists.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val is_directory </I>
|
|
|
|
:
|
|
<B>string -> bool</B>
|
|
|
|
<P>
|
|
Returns
|
|
<B>true</B>
|
|
|
|
if the given name refers to a directory,
|
|
<B>false</B>
|
|
|
|
if it refers to another kind of file.
|
|
Raise
|
|
<B>Sys_error</B>
|
|
|
|
if no file exists with the given name.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
3.10.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val remove </I>
|
|
|
|
:
|
|
<B>string -> unit</B>
|
|
|
|
<P>
|
|
Remove the given file name from the file system.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val rename </I>
|
|
|
|
:
|
|
<B>string -> string -> unit</B>
|
|
|
|
<P>
|
|
Rename a file.
|
|
<B>rename oldpath newpath</B>
|
|
|
|
renames the file
|
|
called
|
|
<B>oldpath</B>
|
|
|
|
, giving it
|
|
<B>newpath</B>
|
|
|
|
as its new name,
|
|
moving it between directories if needed. If
|
|
<B>newpath</B>
|
|
|
|
already
|
|
exists, its contents will be replaced with those of
|
|
<B>oldpath</B>
|
|
|
|
.
|
|
Depending on the operating system, the metadata (permissions,
|
|
owner, etc) of
|
|
<B>newpath</B>
|
|
|
|
can either be preserved or be replaced by
|
|
those of
|
|
<B>oldpath</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.06 concerning the "replace existing file" behavior
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getenv </I>
|
|
|
|
:
|
|
<B>string -> string</B>
|
|
|
|
<P>
|
|
Return the value associated to a variable in the process
|
|
environment. Raise
|
|
<B>Not_found</B>
|
|
|
|
if the variable is unbound.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getenv_opt </I>
|
|
|
|
:
|
|
<B>string -> string option</B>
|
|
|
|
<P>
|
|
Return the value associated to a variable in the process
|
|
environment or
|
|
<B>None</B>
|
|
|
|
if the variable is unbound.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.05
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val command </I>
|
|
|
|
:
|
|
<B>string -> int</B>
|
|
|
|
<P>
|
|
Execute the given shell command and return its exit code.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val time </I>
|
|
|
|
:
|
|
<B>unit -> float</B>
|
|
|
|
<P>
|
|
Return the processor time, in seconds, used by the program
|
|
since the beginning of execution.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val chdir </I>
|
|
|
|
:
|
|
<B>string -> unit</B>
|
|
|
|
<P>
|
|
Change the current working directory of the process.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getcwd </I>
|
|
|
|
:
|
|
<B>unit -> string</B>
|
|
|
|
<P>
|
|
Return the current working directory of the process.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val readdir </I>
|
|
|
|
:
|
|
<B>string -> string array</B>
|
|
|
|
<P>
|
|
Return the names of all files present in the given directory.
|
|
Names denoting the current directory and the parent directory
|
|
(
|
|
<B>.</B>
|
|
|
|
and
|
|
<B>..</B>
|
|
|
|
in Unix) are not returned. Each string in the
|
|
result is a file name rather than a complete path. There is no
|
|
guarantee that the name strings in the resulting array will appear
|
|
in any specific order; they are not, in particular, guaranteed to
|
|
appear in alphabetical order.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val interactive </I>
|
|
|
|
:
|
|
<B>bool ref</B>
|
|
|
|
<P>
|
|
This reference is initially set to
|
|
<B>false</B>
|
|
|
|
in standalone
|
|
programs and to
|
|
<B>true</B>
|
|
|
|
if the code is being executed under
|
|
the interactive toplevel system
|
|
<B>ocaml</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val os_type </I>
|
|
|
|
:
|
|
<B>string</B>
|
|
|
|
<P>
|
|
Operating system currently executing the OCaml program. One of
|
|
<P>
|
|
-
|
|
<B>Unix</B>
|
|
|
|
(for all Unix versions, including Linux and Mac OS X),
|
|
<P>
|
|
-
|
|
<B>Win32</B>
|
|
|
|
(for MS-Windows, OCaml compiled with MSVC++ or Mingw),
|
|
<P>
|
|
-
|
|
<B>Cygwin</B>
|
|
|
|
(for MS-Windows, OCaml compiled with Cygwin).
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>type backend_type </I>
|
|
|
|
=
|
|
<BR> | Native
|
|
<BR> | Bytecode
|
|
<BR> | Other
|
|
<B>of </B>
|
|
|
|
<B>string</B>
|
|
|
|
<BR>
|
|
<P>
|
|
Currently, the official distribution only supports
|
|
<B>Native</B>
|
|
|
|
and
|
|
<B>Bytecode</B>
|
|
|
|
, but it can be other backends with alternative
|
|
compilers, for example, javascript.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.04.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val backend_type </I>
|
|
|
|
:
|
|
<B>backend_type</B>
|
|
|
|
<P>
|
|
Backend type currently executing the OCaml program.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.04.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val unix </I>
|
|
|
|
:
|
|
<B>bool</B>
|
|
|
|
<P>
|
|
True if
|
|
<B>Sys.os_type = Unix</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.01.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val win32 </I>
|
|
|
|
:
|
|
<B>bool</B>
|
|
|
|
<P>
|
|
True if
|
|
<B>Sys.os_type = Win32</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.01.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val cygwin </I>
|
|
|
|
:
|
|
<B>bool</B>
|
|
|
|
<P>
|
|
True if
|
|
<B>Sys.os_type = Cygwin</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.01.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val word_size </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Size of one word on the machine currently executing the OCaml
|
|
program, in bits: 32 or 64.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val int_size </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Size of
|
|
<B>int</B>
|
|
|
|
, in bits. It is 31 (resp. 63) when using OCaml on a
|
|
32-bit (resp. 64-bit) platform. It may differ for other implementations,
|
|
e.g. it can be 32 bits when compiling to JavaScript.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val big_endian </I>
|
|
|
|
:
|
|
<B>bool</B>
|
|
|
|
<P>
|
|
Whether the machine currently executing the Caml program is big-endian.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.00.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val max_string_length </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Maximum length of strings and byte sequences.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val max_array_length </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Maximum length of a normal array (i.e. any array whose elements are
|
|
not of type
|
|
<B>float</B>
|
|
|
|
). The maximum length of a
|
|
<B>float array</B>
|
|
|
|
is
|
|
<B>max_floatarray_length</B>
|
|
|
|
if OCaml was configured with
|
|
<B>--enable-flat-float-array</B>
|
|
|
|
and
|
|
<B>max_array_length</B>
|
|
|
|
if configured
|
|
with
|
|
<B>--disable-flat-float-array</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val max_floatarray_length </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Maximum length of a floatarray. This is also the maximum length of
|
|
a
|
|
<B>float array</B>
|
|
|
|
when OCaml is configured with
|
|
<B>--enable-flat-float-array</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val runtime_variant </I>
|
|
|
|
:
|
|
<B>unit -> string</B>
|
|
|
|
<P>
|
|
Return the name of the runtime variant the program is running on.
|
|
This is normally the argument given to
|
|
<B>-runtime-variant</B>
|
|
|
|
at compile
|
|
time, but for byte-code it can be changed after compilation.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val runtime_parameters </I>
|
|
|
|
:
|
|
<B>unit -> string</B>
|
|
|
|
<P>
|
|
Return the value of the runtime parameters, in the same format
|
|
as the contents of the
|
|
<B>OCAMLRUNPARAM</B>
|
|
|
|
environment variable.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H3>Signal handling</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type signal_behavior </I>
|
|
|
|
=
|
|
<BR> | Signal_default
|
|
<BR> | Signal_ignore
|
|
<BR> | Signal_handle
|
|
<B>of </B>
|
|
|
|
<B>(int -> unit)</B>
|
|
|
|
<BR>
|
|
<P>
|
|
What to do when receiving a signal:
|
|
<P>
|
|
-
|
|
<B>Signal_default</B>
|
|
|
|
: take the default behavior
|
|
(usually: abort the program)
|
|
<P>
|
|
-
|
|
<B>Signal_ignore</B>
|
|
|
|
: ignore the signal
|
|
<P>
|
|
-
|
|
<B>Signal_handle f</B>
|
|
|
|
: call function
|
|
<B>f</B>
|
|
|
|
, giving it the signal
|
|
number as argument.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val signal </I>
|
|
|
|
:
|
|
<B>int -> signal_behavior -> signal_behavior</B>
|
|
|
|
<P>
|
|
Set the behavior of the system on receipt of a given signal. The
|
|
first argument is the signal number. Return the behavior
|
|
previously associated with the signal. If the signal number is
|
|
invalid (or not available on your system), an
|
|
<B>Invalid_argument</B>
|
|
|
|
exception is raised.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val set_signal </I>
|
|
|
|
:
|
|
<B>int -> signal_behavior -> unit</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>Sys.signal</B>
|
|
|
|
but return value is ignored.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H3>Signal numbers for the standard POSIX signals.</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val sigabrt </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Abnormal termination
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigalrm </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Timeout
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigfpe </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Arithmetic exception
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sighup </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Hangup on controlling terminal
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigill </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Invalid hardware instruction
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigint </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Interactive interrupt (ctrl-C)
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigkill </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Termination (cannot be ignored)
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigpipe </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Broken pipe
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigquit </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Interactive termination
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigsegv </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Invalid memory reference
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigterm </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Termination
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigusr1 </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Application-defined signal 1
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigusr2 </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Application-defined signal 2
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigchld </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Child process terminated
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigcont </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Continue
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigstop </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Stop
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigtstp </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Interactive stop
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigttin </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Terminal read from background process
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigttou </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Terminal write from background process
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigvtalrm </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Timeout in virtual time
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigprof </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Profiling interrupt
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigbus </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Bus error
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigpoll </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Pollable event
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigsys </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Bad argument to routine
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigtrap </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Trace/breakpoint trap
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigurg </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Urgent condition on socket
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigxcpu </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
Timeout in cpu time
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigxfsz </I>
|
|
|
|
:
|
|
<B>int</B>
|
|
|
|
<P>
|
|
File size limit exceeded
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>exception Break </I>
|
|
|
|
<P>
|
|
<P>
|
|
Exception raised on interactive interrupt if
|
|
<B>Sys.catch_break</B>
|
|
|
|
is on.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val catch_break </I>
|
|
|
|
:
|
|
<B>bool -> unit</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>catch_break</B>
|
|
|
|
governs whether interactive interrupt (ctrl-C)
|
|
terminates the program or raises the
|
|
<B>Break</B>
|
|
|
|
exception.
|
|
Call
|
|
<B>catch_break true</B>
|
|
|
|
to enable raising
|
|
<B>Break</B>
|
|
|
|
,
|
|
and
|
|
<B>catch_break false</B>
|
|
|
|
to let the system
|
|
terminate the program on user interrupt.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val ocaml_version </I>
|
|
|
|
:
|
|
<B>string</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>ocaml_version</B>
|
|
|
|
is the version of OCaml.
|
|
It is a string of the form
|
|
<B>major.minor[.patchlevel][+additional-info]</B>
|
|
|
|
,
|
|
where
|
|
<B>major</B>
|
|
|
|
,
|
|
<B>minor</B>
|
|
|
|
, and
|
|
<B>patchlevel</B>
|
|
|
|
are integers, and
|
|
<B>additional-info</B>
|
|
|
|
is an arbitrary string. The
|
|
<B>[.patchlevel]</B>
|
|
|
|
and
|
|
<B>[+additional-info]</B>
|
|
|
|
parts may be absent.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val enable_runtime_warnings </I>
|
|
|
|
:
|
|
<B>bool -> unit</B>
|
|
|
|
<P>
|
|
Control whether the OCaml runtime system can emit warnings
|
|
on stderr. Currently, the only supported warning is triggered
|
|
when a channel created by
|
|
<B>open_*</B>
|
|
|
|
functions is finalized without
|
|
being closed. Runtime warnings are enabled by default.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val runtime_warnings_enabled </I>
|
|
|
|
:
|
|
<B>unit -> bool</B>
|
|
|
|
<P>
|
|
Return whether runtime warnings are currently enabled.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Optimization</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val opaque_identity </I>
|
|
|
|
:
|
|
<B>'a -> 'a</B>
|
|
|
|
<P>
|
|
For the purposes of optimization,
|
|
<B>opaque_identity</B>
|
|
|
|
behaves like an
|
|
unknown (and thus possibly side-effecting) function.
|
|
<P>
|
|
At runtime,
|
|
<B>opaque_identity</B>
|
|
|
|
disappears altogether.
|
|
<P>
|
|
A typical use of this function is to prevent pure computations from being
|
|
optimized away in benchmarking loops. For example:
|
|
<B>for _round = 1 to 100_000 do</B>
|
|
|
|
|
|
|
|
<B>ignore (Sys.opaque_identity (my_pure_computation ()))</B>
|
|
|
|
<B>done</B>
|
|
|
|
<B></B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">Module</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">Documentation</A><DD>
|
|
<DL>
|
|
<DT id="4"><A HREF="#lbAE">Signal handling</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">Signal numbers for the standard POSIX signals.</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">Optimization</A><DD>
|
|
</DL>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:57 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|