`Str.regexp_string s` returns a regular expression that matches exactly `s` and nothing else.

`val regexp_string_caseFold: string -> regexp`

`Str.regexp_string_caseFold` is similar to `Str.regexp_string`[32.1], but the regexp matches in a case-insensitive way.

## String matching and searching

`val string_match: regexp -> string -> int -> bool`

`string_match r s start` tests whether a substring of `s` that starts at position `start` matches the regular expression `r`. The first character of a string has position 0, as usual.

`val search_forward: regexp -> string -> int -> int`

`search_forward r s start` searches the string `s` for a substring matching the regular expression `r`. The search starts at position `start` and proceeds towards the end of the string. Return the position of the first character of the matched substring.

**Raises** `Not_found` if no substring matches.

`val search_backward: regexp -> string -> int -> int`

`search_backward r s last` searches the string `s` for a substring matching the regular expression `r`. The search first considers substrings that start at position `last` and proceeds towards the beginning of string. Return the position of the first character of the matched substring.

**Raises** `Not_found` if no substring matches.

`val string_partial_match: regexp -> string -> int -> bool`

Similar to `Str.String_match`[32.1], but also returns true if the argument `string` is a prefix of a string that matches. This includes the case of a true complete match.

`val matched_string: string -> string`

`matched_string s` returns the substring of `s` that was matched by the last call to one of the following matching or searching functions:

* `Str.String_match`[32.1]

* `Str.search_forward`[32.1]

* `Str.search_backward`[32.1]

* `Str.String_partial_match`[32.1]

* `Str.global_substitute`[32.1]

* `Str.substitute_first`[32.1]

provided that none of the following functions was called in between:

* `Str.global_replace`[32.1]
val group_end : int -> int

group_end n returns the position of the character following the last character of substring
that was matched by the nth group of the regular expression that was matched by the last
call to a matching or searching function (see Str.matched_string[32.1] for details).

Raises

* `Not_found` if the nth group of the regular expression was not matched.

* `Invalid_argument` if there are fewer than n groups in the regular expression.

Replacement

val global_replace : regexp -> string -> string -> string

global_replace regexp `templ` s returns a string identical to s, except that all substrings
of s that match regexp have been replaced by `templ`. The replacement template `templ` can
contain `\1`, `\2`, etc; these sequences will be replaced by the text matched by the
corresponding group in the regular expression. `\0` stands for the text matched by the whole
regular expression.

val replace_first : regexp -> string -> string -> string

Same as `Str.global_replace[32.1]`, except that only the first substring matching the regular
expression is replaced.

val global_substitute : regexp -> (string -> string) -> string -> string

global_substitute regexp `subst` s returns a string identical to s, except that all
substrings of s that match regexp have been replaced by the result of function `subst`. The
function `subst` is called once for each matching substring, and receives s (the whole text) as
argument.

val substitute_first : regexp -> (string -> string) -> string -> string

Same as `Str.global_substitute[32.1]`, except that only the first substring matching the
regular expression is replaced.

val replace_matched : string -> string -> string

`replace_matched repl s` returns the replacement text `repl` in which `\1`, `\2`, etc. have been
replaced by the text matched by the corresponding groups in the regular expression that was
matched by the last call to a matching or searching function (see `Str.matched_string[32.1]`
for details). `s` must be the same string that was passed to the matching or searching function.

Splitting

val split : regexp -> string -> string list
`split` `r` `s` splits `s` into substrings, taking as delimiters the substrings that match `r`, and returns the list of substrings. For instance, `split (regexp "[ \t]+") s` splits `s` into blank-separated words. An occurrence of the delimiter at the beginning or at the end of the string is ignored.

**`val bounded_split : regexp -> string -> int -> string list`**

Same as `Str.split[32.1]`, but splits into at most `n` substrings, where `n` is the extra integer parameter.

**`val split_delim : regexp -> string -> string list`**

Same as `Str.split[32.1]` but occurrences of the delimiter at the beginning and at the end of the string are recognized and returned as empty strings in the result. For instance, `split_delim (regexp " " ) " abc "` returns `[]"; "abc"; ""]`, while `split` with the same arguments returns `"abc"`.

**`val bounded_split_delim : regexp -> string -> int -> string list`**

Same as `Str.bounded_split[32.1]`, but occurrences of the delimiter at the beginning and at the end of the string are recognized and returned as empty strings in the result.

**`type split_result =`**

Text of string

Delim of string

**`val full_split : regexp -> string -> split_result list`**

Same as `Str.split_delim[32.1]`, but returns the delimiters as well as the substrings contained between delimiters. The former are tagged `Delim` in the result list; the latter are tagged `Text`. For instance, `full_split (regexp "[{}]") "{ab}"` returns `[Delim "{"; Text "ab"; Delim "}"]`.

**`val bounded_full_split : regexp -> string -> int -> split_result list`**

Same as `Str.bounded_split_delim[32.1]`, but returns the delimiters as well as the substrings contained between delimiters. The former are tagged `Delim` in the result list; the latter are tagged `Text`.

## Extracting substrings

**`val string_before : string -> int -> string`**

`string_before s n` returns the substring of all characters of `s` that precede position `n` (excluding the character at position `n`).

**`val string_after : string -> int -> string`**

`string_after s n` returns the substring of all characters of `s` that follow position `n` (including the character at position `n`).

**`val first_chars : string -> int -> string`**
`first_chars s n` returns the first `n` characters of `s`. This is the same function as `Str_string_before[32.1]`.

`val last_chars : string -> int -> string`

`last_chars s n` returns the last `n` characters of `s`.
Chapter 33

The runtime_events library

The `runtime_events` library provides an API for consuming runtime tracing and metrics information from the runtime. See chapter 25 for more information.

Programs that use `runtime_events` must be linked as follows:

```
ocamlc -I +runtime_events other options unix.cma runtime_events.cma other files
ocamlopt -I +runtime_events other options unix.cmxa runtime_events.cmxa other files
```

Compilation units that use the `runtime_events` library must also be compiled with the `-I +runtime_events` option (see chapter 13).

## 33.1 Module Runtime_events: Runtime events - ring buffer-based runtime tracing

This module enables users to enable and subscribe to tracing events from the Garbage Collector and other parts of the OCaml runtime. This can be useful for diagnostic or performance monitoring purposes. This module can be used to subscribe to events for the current process or external processes asynchronously.

When enabled (either via setting the `OCAML_RUNTIME EVENTS START` environment variable or calling `Runtime_events.start`) a file with the pid of the process and extension `.events` will be created. By default this is in the current directory but can be over-ridden by the `OCAML_RUNTIME EVENTS DIR` environment variable. Each domain maintains its own ring buffer in a section of the larger file into which it emits events.

There is additionally a set of C APIs in `runtime_events.h` that can enable zero-impact monitoring of the current process or bindings for other languages.

The runtime events system's behaviour can be controlled by the following environment variables:

* `OCAML_RUNTIME EVENTS START` if set will cause the runtime events system to be started as part of the OCaml runtime initialization.

* `OCAML_RUNTIME EVENTS DIR` sets the directory where the runtime events ring buffers will be located. If not present the program's working directory will be used.
* OCAML_RUNTIME EVENTS_PRESERVE if set will prevent the OCaml runtime from removing its ring buffers when it terminates. This can help if monitoring very short running programs.

type runtime_counter =

| EV_C_FORCE_MINOR_ALLOC_SMALL

Triggering of a minor collection due to a full minor heap.

Since: 5.0

| EV_C_FORCE_MINOR_MAKE_VECT

Triggering of a minor collection due to Array.make.

Since: 5.0

| EV_C_FORCE_MINOR_SET_MINOR_heap_SIZE

Triggering of a minor collection due to Gc.minor_heap_size.

Since: 5.0

| EV_C_FORCE_MINOR_MEMPROF

Triggering of a minor collection during memprof young sampling.

Since: 5.3

| EV_C_MINOR_PROMOTED

Total words promoted from the minor heap to the major in the last minor collection.

Since: 5.0

| EV_C_MINOR_ALLOCATED

Total bytes allocated in the minor heap in the last minor collection.

Since: 5.0

| EV_C_REQUEST_MAJOR_ALLOC_SHR

Major slice requested due to allocation in major heap.

Since: 5.0

| EV_C_REQUEST_MAJOR_ADJUST_GC_SPEED

Major slice requested by camlAdjust_gc_speed.

Since: 5.0

| EV_C_REQUEST_MINOR_REALLOC_REF_TABLE

Triggering of a minor collection due to ref table reallocation.

Since: 5.0

| EV_C_REQUEST_MINOR_REALLOC_EPHE_REF_TABLE

Triggering of a minor collection due to ephe_ref table reallocation.

Since: 5.0
| EV_C_REQUEST_MINOR REALLOC_CUSTOM_TABLE

Triggering of a minor collection due to custom table reallocation.

Since: 5.0

| EV_C_MAJOR_HARP POOL_WORDS

Total words in a Domain's major heap pools. This is the sum of unallocated and live
words in each pool.

Since: 5.1

| EV_C_MAJOR_heap_POOL_LIVE_words

Current live words in a Domain's major heap pools.

Since: 5.1

| EV_C_MAJOR_heap_LARGE_words

Total words of a Domain's major heap large allocations. A large allocation is an
allocation larger than the largest sized pool.

Since: 5.1

| EV_C_MAJOR_heap_POOL_FRAG_words

Words in a Domain's major heap pools lost to fragmentation. This is due to there not
being a pool with the exact size of an allocation and a larger sized pool needing to be
used.

Since: 5.1

| EV_C_MAJOR_heap_POOL_LIVE_BLOCKs

Live blocks of a Domain's major heap pools.

Since: 5.1

| EV_C_MAJOR_heap_LARGE_BLOCKs

Live blocks of a Domain's major heap large allocations.

Since: 5.1

| EV_C_MAJOR_heap_words

Major heap size in words of a Domain.

Since: 5.3

| EV_C_MAJOR_ALLOCATED_words

Allocations to the major heap of this Domain in words, since the last major slice.

Since: 5.3

| EV_C_MAJOR_ALLOCATED WORK

The amount of major GC 'work' needing to be done as a result of allocations to the
major heap of this Domain in words, since the last major slice.

Since: 5.3

| EV_C_MAJOR_DEPENDENT WORK
The amount of major GC 'work' needing to be done as a result of dependent
allocations to the major heap of this Domain in words, since the last major slice.
Dependent memory is non-heap memory that depends on heap memory being collected
in order to be freed.

Since: 5.3

| EV_C_MAJOR_EXTRA WORK

The amount of major GC 'work' needing to be done as a result of extra non-memory
resources that are dependent on heap memory being collected in order to be freed.

Since: 5.3

| EV_C_MAJOR WORK COUNTER

The global amount of major GC 'work' done by all domains since the program began.

Since: 5.3

| EV_C_MAJOR_ALLOC COUNTER

The global words of major GC allocations done by all domains since the program
began.

Since: 5.3

| EV_C_MAJOR_SLICE_TARGET

The target amount of global 'work' that should be done by all domains at the end of
the major slice (see EV_C_MAJOR_SLICE_COUNTER).

Since: 5.3

| EV_C_MAJOR_SLICE_BUDGET

The budget in 'work' that a domain has to do during the major slice.

Since: 5.3

The type for counter events emitted by the runtime. Counter events are used to measure a quantity at a point in time or record the occurence of an event. In the latter case their value will be one.

type runtime_phase =

| EV_EXPLICIT_GC_SET

Event spanning a call to Gc.set.

Since: 5.0

| EV_EXPLICIT_GC_STAT

Event spanning a call to Gc.stat.

Since: 5.0

| EV_EXPLICIT_GC_MINOR

Event spanning a call to Gc.minor, which forces a minor collection.

Since: 5.0
| EV_EXPLICIT_GC_MAJOR

Event spanning a call to Gc.major, which forces a major collection.

Since: 5.0

| EV_EXPLICIT_GC_FULL_MAJOR

Event spanning a call to Gc.full_major, which forces a full major collection.

Since: 5.0

| EV_EXPLICIT_GC_COMPACT

Event spanning a call to Gc.compact, which triggers a compaction.

Since: 5.0

| EV_MAJOR

Event spanning any major GC work.

Since: 5.0

| EV_MAJOR_SWEEP

Event spanning the sweeping work of a major GC.

Since: 5.0

| EV_MAJOR_mark_roots

Event spanning the marking of roots in a major GC.

Since: 5.0

| EV_MAJOR_MEMPROF_roots

Event spanning the marking of memprof roots in a major GC.

Since: 5.3

| EV_MAJOR_mark

Event spanning the marking of the heap in a major GC.

Since: 5.0

| EV_MINOR

Event spanning any minor GC work.

Since: 5.0

| EV_MINOR_LOCAL_roots

Event spanning the scanning and major allocation of local roots during a minor GC.

Since: 5.0

| EV_MINOR_MEMPROF_roots

Event spanning the scanning and promotion of memprof roots in a minor GC.

Since: 5.3

| EV_MINOR_MEMPROF_CLEAN
Event spanning cleaning and updating of memprof structures at the end of a minor GC.

**Since: 5.3**

| EV_MINOR_FINALIZED

Event spanning the running of finalisers for dead custom blocks at the end of a minor GC.

**Since: 5.0**

| EV_EXPLICIT_GC_MAJOR_SLICE

Event spanning a call to Gc.major_slice.

**Since: 5.0**

| EV_FINALISE_UPDATE_FIRST

Event spanning time spent in the first phase of finalisation at the end of a major GC cycle.

**Since: 5.0**

| EV_FINALISE_UPDATE_LAST

Event spanning time spent in the last phase of finalisation at the end of a major GC cycle.

**Since: 5.0**

| EV_INTERRUPT_REMOVE

Event spanning work triggered by an interrupt from another domain. This is usually a stop-the-world request.

**Since: 5.0**

| EV_MAJOR_EPHE_mark

Event spanning the marking of ephemeron tables in a major GC.

**Since: 5.0**

| EV_MAJOR_EPHE SWEEP

Event spanning the sweeping of ephemeron tables in a major GC.

**Since: 5.0**

| EV_MAJOR_FINISH_marking

Event spanning work done at the end of marking in a major GC.

**Since: 5.0**

| EV_MAJOR_GCotsCYCLEvDOMAInS

Event spanning work done at the end of a major GC cycle. This includes a minor collection.

**Since: 5.0**

| EV_MAJOR_GCwPHASEChange
| EV_STW_LEADER

Event spanning the time spent as the leader of a stop-the-world.

Since: 5.0

| EV_MAJOR_FINISH_SWEEPING

Event spanning the time spent finishing sweeping when forced to as part of domain termination.

Since: 5.0

| EV_MAJOR_MEMPROF_CLEAN

Event spanning the time spent cleaning memprof structures at the end of a major GC.

Since: 5.3

| EV_MINOR_FINALIZERS_ADMIN

Event spanning finalisers book-keeping at the end of a minor GC.

Since: 5.0

| EV_MINOR_REMEMBERED_SET

Event spanning the scanning and major allocation of remembered sets during a minor GC.

Since: 5.0

| EV_MINOR_REMEMBERED_SET_PROMOTE

Event spanning the promotion of blocks in the remembered set and global roots during a minor GC.

Since: 5.0

| EV_MINOR_LOCAL_ROOTS_PROMOTE

Event spanning the promotion of local roots during a minor GC.

Since: 5.0

| EV_domain_CONDITION_WAIT

Event spanning waiting in Condition.wait.

Since: 5.0

| EV_domain_resize_heap_reserveATION

Event spanning resizing the domain heap reservation, as a result of minor heap size changes.

Since: 5.0

| EV_COMPACT

Event spanning compaction of the heap during a call to Gc.compact.

Since: 5.2

| EV_COMPACT_EVACUATE
Event spanning evacuating major GC pools during a compaction.

**Since: 5.2**

| EV_COMPACT_FORWARD

Event spanning the walking of the heap to update changed pointers after an evacuation
during a compaction.

**Since: 5.2**

| EV_COMPACT_RELEASE

Event spanning releasing the evacuated pools at the end of a compaction.

**Since: 5.2**

| EV_EMPTY_MINOR

Event spanning a domain needing to empty its minor heap for a new allocation. This
includes time spent trying to become stop-the-world leader.

**Since: 5.4**

The type for span events emitted by the runtime.

type lifecycle =

| EV_RING_START

Event indicating that the Runtime_events ring buffer has been started. Includes the
PID of the process as an argument.

**Since: 5.0**

| EV_RING_STOP

Event indicating that the Runtime_events ring buffer has been stopped.

**Since: 5.0**

| EV_RING_pause

Event indicating that the Runtime_events ring buffer has been paused.

**Since: 5.0**

| EV_RINGRESUME

Event indicating that the Runtime_events ring buffer has been resumed.

**Since: 5.0**

| EV_FORK PARENT

Event indicating that a fork has occurred and the current domain is the parent.
Includes the PID of the child as an argument.

**Since: 5.0**

| EV_FORK meLd

Event indicating that a fork has occurred and the current domain is the child.

**Since: 5.0**
| EV_DOMAIN_SPAWN

Event indicating that a new domain has been spawned. Includes the PID of the new
domain as an argument.

Since: 5.0

| EV_DOMAIN_TERMINATE

Event indicating that a domain has terminated. Includes the PID of the domain as an argument.

Since: 5.0

Lifecycle events for Runtime_events and domains.

val lifecycle_name : lifecycle -> string

Return a string representation of a given lifecycle event type.

val runtime_phase_name : runtime_phase -> string

Return a string representation of a given runtime phase event type.

val runtime_counter_name : runtime_counter -> string

Return a string representation of a given runtime counter type.

type cursor

Type of the cursor used when consuming.

module Timestamp :

sig

type t

Type for the int64 timestamp to allow for future changes.

val to_int64 : t -> int64

val get_current : unit -> t

Access the current timestamp. The timestamp is incremented by one every nanosecond, but the starting point is unspecified.

Since: 5.4

end

module Type :

sig

type 'a t

The type for a user event content type.

val unit : unit t
An event that has no data associated with it.

type span =

| Begin

| End

val span : span t

An event that has a beginning and an end.

val int : int t

An event containing an integer value.

val register :

encode: (bytes -> 'a -> int) ->

decode: (bytes -> int -> 'a) -> 'a t

Registers a custom type by providing an encoder and a decoder. The encoder writes the value in the provided buffer and returns the number of bytes written. The decoder gets a slice of the buffer of specified length, and returns the decoded value.

The maximum value length is 1024 bytes.

end

module User :

sig

User events is a way for libraries to provide runtime events that can be consumed by other tools. These events can carry known data types or custom values. The current maximum number of user events is 8192.

type tag = ..

The type for a user event tag. Tags are used to discriminate between user events of the same type.

type 'value t

The type for a user event. User events describe their tag, carried data type and an unique string-based name.

val register : string ->

tag ->

'value Runtime_events.Type.t -> 'value t

register name tag ty registers a new event with an unique name, carrying a tag and values of type ty.

val write : 'value t -> 'value -> unit

write t v emits value v for event t.
```kotlin
val name: 'a t -> string
```

name `t` is the unique identifying name of event `t`.

```kotlin
val tag: 'a t -> tag
```

tag `t` is the associated tag of event `t`, when it is known. An event can be unknown if it was not registered in the consumer program.

end

module Callbacks :

sig

type `t`

Type of callbacks.

```kotlin
val create :
```

```kotlin
?runtime_begin: (int ->
    Runtime_events Timestamp.t ->
    Runtime_events runtime_phase -> unit) ->
```

```kotlin
?runtime_end: (int ->
    Runtime_events Timestamp.t ->
    Runtime_events runtime_phase -> unit) ->
```

```kotlin
?runtime_counter: (int ->
    Runtime_events Timestamp.t ->
    Runtime_events runtime_counter -> int -> unit) ->
```

```kotlin
?alloc: (int -> Runtime_events Timestamp.t -> int array -> unit) ->
```

```kotlin
?lifecycle: (int ->
    Runtime_events Timestamp.t ->
    Runtime_events lifecycle -> int option -> unit) ->
```

```kotlin
?lost_events: (int -> int -> unit) -> unit -> t
```

Create a `Callback` that optionally subscribes to one or more runtime events. The first `int` supplied to callbacks is the ring buffer index. Each domain owns a single ring buffer for the duration of the domain's existence. After a domain terminates, a newly spawned domain may take ownership of the ring buffer. A `runtime_begin` callback is called when the runtime enters a new phase (e.g a `runtime_begin` with `EV_MINOR` is called at the start of a minor GC). A `runtime_end` callback is called when the runtime leaves a certain phase. The `runtime_counter` callback is called when a counter is emitted by the runtime. `lifecycle` callbacks are called when the ring undergoes a change in lifecycle and a consumer may need to respond. `alloc` callbacks are currently only called on the instrumented runtime. `lost_events` callbacks are called if the consumer code detects some unconsumed events have been overwritten.

```kotlin
val add_user_event :
```

```kotlin
'a Runtime_events.Type.t ->
(int -> Runtime_events Timestamp.t -> 'a Runtime_events.User.t -> 'a -> unit) ->
t -> t
```
`add_user_event` `ty` `callback` `t` extends `t` to additionally subscribe to user events of type `ty`. When such an event happens, `callback` is called with the corresponding event and payload.

`end`

`val start : unit -> unit`

`start ()` will start the collection of events in the runtime if not already started.

Events can be consumed by creating a cursor with `create_cursor` and providing a set of callbacks to be called for each type of event.

`val path : unit -> string option`

If runtime events are being collected, `path ()` returns `Some p` where `p` is a path to the runtime events file. Otherwise, it returns `None`.

`val pause : unit -> unit`

`pause ()` will pause the collection of events in the runtime. Traces are collected if the program has called `Runtime_events.start ()` or the `OCAML_RUNTIME_events_START` environment variable has been set.

`val resume : unit -> unit`

`resume ()` will resume the collection of events in the runtime. Traces are collected if the program has called `Runtime_events.start ()` or the `OCAML_RUNTIME_events_START` environment variable has been set.

`val create_cursor : (string * int) option -> cursor`

`create_cursor path_pid` creates a cursor to read from an `runtime_events`. Cursors can be created for `runtime_events` in and out of process. A `runtime_events` ring-buffer may have multiple cursors reading from it at any point in time and a program may have multiple cursors open concurrently (for example if multiple consumers want different sets of events). If `path_pid` is `None` then a cursor is created for the current process. Otherwise the pair contains a string `path` to the directory that contains the `pid.events` file and `int pid` for the `runtime_events` of an external process to monitor.

`val free_cursor : cursor -> unit`

Free a previously created `runtime_events` cursor.

`val read_poll : cursor -> Callbacks.t -> int option -> int`

`read_poll cursor callbacks max_option` calls the corresponding functions on `s` for up to `max_option` events read off `cursor`'s `runtime_events` and returns the number of events read.
# Chapter 34

## The threads library

The `threads` library allows concurrent programming in OCaml. It provides multiple threads of control (also called lightweight processes) that execute concurrently in the same memory space. Threads communicate by in-place modification of shared data structures, or by sending and receiving data on communication channels.

The `threads` library is implemented on top of the threading facilities provided by the operating system: POSIX 1003.1c threads for Linux, MacOS, and other Unix-like systems; Win32 threads for Windows. Only one thread at a time is allowed to run OCaml code on a particular domain 9.5.1. Hence, opportunities for parallelism are limited to the parts of the program that run system or C library code. However, threads provide concurrency and can be used to structure programs as several communicating processes. Threads also efficiently support concurrent, overlapping I/O operations.

Programs that use threads must be linked as follows:

```
ocamlc -I +unix -I +threads other options unix.cma threads.cma other files
```

```
ocamlopt -I +unix -I +threads other options unix.cmxa threads.cmxa other files
```

Compilation units that use the `threads` library must also be compiled with the `-I +threads` option (see chapter 13).

### 34.1 Module Thread : Lightweight threads for Posix 1003.1c and Win32.

```
type t
```

The type of thread handles.

#### Thread creation and termination

```
val create : ('a -> 'b) -> 'a -> t
```

`Thread.create` `funct arg` creates a new thread of control, in which the function application `funct arg` is executed concurrently with the other threads of the domain. The application of
`Thread.create` returns the handle of the newly created thread. The new thread terminates when the application `funct arg` returns, either normally or by raising the `Thread文化的Exit` [34.1] exception or by raising any other uncaught exception. In the last case, the uncaught exception is printed on standard error, but not propagated back to the parent thread. Similarly, the result of the application `funct arg` is discarded and not directly accessible to the parent thread.

See also `Domain spawn` [29.14] if you want parallel execution instead.

`val self: unit -> t`

Return the handle for the thread currently executing.

`val id: t -> int`

Return the identifier of the given thread. A thread identifier is an integer that identifies uniquely the thread. It can be used to build data structures indexed by threads.

`val set_current_thread_name: string -> unit`

Set the thread's name. This should be called from within the thread function. Setting thread name is available on most systems.

This does nothing if the functionality is not implemented but will print a warning on the standard error if enabled.

Likewise, a warning is printed if the operation fails.

**Since: 5.4**

**exception Exit**

Exception raised by user code to initiate termination of the current thread. In a thread created by `Thread.create` [34.1] `funct arg`, if the `Thread文化的Exit` [34.1] exception reaches the top of the application `funct arg`, it has the effect of terminating the current thread silently. In other contexts, there is no implicit handling of the `Thread文化的Exit` [34.1] exception.

`val exit: unit -> unit`

*Deprecated.* Use 'raise Thread文化的Exit' instead. Raise the `Thread文化的Exit` [34.1] exception. In a thread created by `Thread.create` [34.1], this will cause the thread to terminate prematurely, unless the thread function handles the exception itself. `Fun.protect` [29.24] finalizers and catch-all exception handlers will be executed.

To make it clear that an exception is raised and will trigger finalizers and catch-all exception handlers, it is recommended to write `raise Thread文化的Exit` instead of `Thread.exit()`.

**Before 5.0** A different implementation was used, not based on raising an exception, and not running finalizers and catch-all handlers. The previous implementation had a different behavior when called outside of a thread created by `Thread.create`.
## Suspending threads

**val delay : float -> unit**

delay d suspends the execution of the calling thread for d seconds. The other program threads continue to run during this time.

**val join : t -> unit**

join th suspends the execution of the calling thread until the thread th has terminated.

**val yield : unit -> unit**

Re-schedule the calling thread without suspending it. This function can be used to give scheduling hints, telling the scheduler that now is a good time to switch to other threads.

## Waiting for file descriptors or processes

The functions below are leftovers from an earlier, VM-based threading system. The Unix[31.1] module provides equivalent functionality, in a more general and more standard-conformant manner. It is recommended to use Unix[31.1] functions directly.

**val wait_timed_read : Unix.file_descr -> float -> bool**

*Deprecated.* Use Unix.select instead. See Thread.wait_timed_write[34.1].

**val wait_timed_write : Unix.file_descr -> float -> bool**

*Deprecated.* Use Unix.select instead. Suspend the execution of the calling thread until at least one character or EOF is available for reading (wait_timed_read) or one character can be written without blocking (wait_timed_write) on the given Unix file descriptor. Wait for at most the amount of time given as second argument (in seconds). Return true if the file descriptor is ready for input/output and false if the timeout expired. The same functionality can be achieved with Unix.select[31.1].

**val select :**

Unix.file_descr list ->

Unix.file_descr list ->

Unix.file_descr list ->

float -> Unix.file_descr list * Unix.file_descr list * Unix.file_descr list

*Deprecated.* Use Unix.select instead. Same function as Unix.select[31.1]. Suspend the execution of the calling thread until input/output becomes possible on the given Unix file descriptors. The arguments and results have the same meaning as for Unix.select[31.1].

**val wait_pid : int -> int * Unix.process_status**

*Deprecated.* Use Unix.waitpid instead. Same function as Unix.waitpid[31.1]. wait_pid p suspends the execution of the calling thread until the process specified by the process identifier p terminates. Returns the pid of the child caught and its termination status, as per Unix.wait[31.1].
## Management of signals

Signal handling follows the POSIX thread model: signals generated by a thread are delivered to that thread; signals generated externally are delivered to one of the threads that does not block it. Each thread possesses a set of blocked signals, which can be modified using `Thread sigmask[34.1]`. This set is inherited at thread creation time. Per-thread signal masks are supported only by the system thread library under Unix, but not under Win32, nor by the VM thread library.

**`val sigmask`: Unix sigprocmask_command -> int list -> int list**

Same function as Unix sigprocmask[31.1]. `sigmask cmd sigs` changes the set of blocked signals for the calling thread. If `cmd` is `SIG_SETMASK`, blocked signals are set to those in the list `sigs`. If `cmd` is `SIG_BLOCK`, the signals in `sigs` are added to the set of blocked signals. If `cmd` is `SIG_UNBLOCK`, the signals in `sigs` are removed from the set of blocked signals. `sigmask` returns the set of previously blocked signals for the thread.

**`val wait_signal`: int list -> int**

Same function as Unix sigwait[31.1]. `wait_signal sigs` suspends the execution of the calling thread until the process receives one of the signals specified in the list `sigs`. It then returns the number of the signal received. Signal handlers attached to the signals in `sigs` will not be invoked. The signals `sigs` are expected to be blocked before calling `wait_signal`.

## Uncaught exceptions

**`val default_uncaught_exception_handler`: exn -> unit**

`Thread.default_uncaught_exception_handler` will print the thread's id, exception and backtrace (if available).

**`val set_uncaught_exception_handler`: (exn -> unit) -> unit**

`Thread.set_uncaught_exception_handler fn` registers `fn` as the handler for uncaught exceptions.

If the newly set uncaught exception handler raise an exception, `Thread.default_uncaught_exception_handler[34.1]` will be called.

## 34.2 Module Event: First-class synchronous communication.

This module implements synchronous inter-thread communications over channels. As in John Reppy's Concurrent ML system, the communication events are first-class values: they can be built and combined independently before being offered for communication.

**`type 'a channel`**

The type of communication channels carrying values of type `'a`.

**`val new_channel`: unit -> 'a channel**

Return a new channel.
type +'a event

The type of communication events returning a result of type 'a.

val send : 'a channel -> 'a -> unit event

send ch v returns the event consisting in sending the value v over the channel ch. The result
value of this event is ().

val receive : 'a channel -> 'a event

receive ch returns the event consisting in receiving a value from the channel ch. The result
value of this event is the value received.

val always : 'a -> 'a event

always v returns an event that is always ready for synchronization. The result value of this
event is v.

val choose : 'a event list -> 'a event

choose evl returns the event that is the alternative of all the events in the list evl.

val wrap : 'a event -> ('a -> 'b) -> 'b event

wrap ev fn returns the event that performs the same communications as ev, then applies the
post-processing function fn on the return value.

val wrap_abort : 'a event -> (unit -> unit) -> 'a event

wrap_abort ev fn returns the event that performs the same communications as ev, but if it
is not selected the function fn is called after the synchronization.

val guard : (unit -> 'a event) -> 'a event

guard fn returns the event that, when synchronized, computes fn() and behaves as the
resulting event. This enables computing events with side-effects at the time of the
synchronization operation.

val sync : 'a event -> 'a

'Synchronize' on an event: offer all the communication possibilities specified in the event to the outside world, and block until one of the communications succeed. The result value of that communication is returned.

val select : 'a event list -> 'a

'Synchronize' on an alternative of events. select evl is shorthand for sync(choose evl).

val poll : 'a event -> 'a option

Non-blocking version of Event.sync[34.2]: offer all the communication possibilities specified
in the event to the outside world, and if one can take place immediately, perform it and
return Some r where r is the result value of that communication. Otherwise, return None
without blocking.
Chapter 35

The dynlink library: dynamic loading
and linking of object files

The dynlink library supports type-safe dynamic loading and linking of bytecode object files (`.cmo` and `.cma` files) in a running bytecode program, or of native plugins (usually `.cmxs` files) in a running native program. Type safety is ensured by limiting the set of modules from the running program that the loaded object file can access, and checking that the running program and the loaded object file have been compiled against the same interfaces for these modules. In native code, there are also some compatibility checks on the implementations (to avoid errors with cross-module optimizations); it might be useful to hide `.cmx` files when building native plugins so that they remain independent of the implementation of modules in the main program.

Programs that use the `dynlink` library simply need to include the dynlink library directory with `-I +dynlink` and link `dynlink.cma` or `dynlink.cmxa` with their object files and other libraries.

**Note:** in order to insure that the dynamically-loaded modules have access to all the libraries that are visible to the main program (and not just to the parts of those libraries that are actually used in the main program), programs using the `dynlink` library should be linked with `-linkall`.

35.1 Module Dynlink: Dynamic loading of .cmo, .cma and .cmxs files.

val is_native : bool

true if the program is native, false if the program is bytecode.

Dynamic loading of compiled files

val loadfile : string -> unit

In bytecode: load the given bytecode object file (`.cmo` file) or bytecode library file (`.cma` file), and link it with the running program. In native code: load the given OCaml plugin file (usually `.cmxs`), and link it with the running program.
All toplevel expressions in the loaded compilation units are evaluated. No facilities are provided to access value names defined by the unit. Therefore, the unit must itself register its entry points with the main program (or a previously-loaded library) e.g. by modifying tables of functions.

An exception will be raised if the given library defines toplevel modules whose names clash with modules existing either in the main program or a shared library previously loaded with `loadfile`. Modules from shared libraries previously loaded with `loadfile_private` are not included in this restriction.

The compilation units loaded by this function are added to the "allowed units" list (see `Dynlink.set_allowed_units[35.1]`).

**val loadfile_private : string -> unit**

Same as `loadfile`, except that the compilation units just loaded are hidden (cannot be referenced) from other modules dynamically loaded afterwards.

An exception will be raised if the given library defines toplevel modules whose names clash with modules existing in either the main program or a shared library previously loaded with `loadfile`. Modules from shared libraries previously loaded with `loadfile_private` are not included in this restriction.

An exception will also be raised if the given library defines toplevel modules whose name matches that of an interface depended on by a module existing in either the main program or a shared library previously loaded with `loadfile`. This applies even if such dependency is only a "module alias" dependency (i.e. just on the name rather than the contents of the interface).

The compilation units loaded by this function are not added to the "allowed units" list (see `Dynlink.set_allowed_units[35.1]`) since they cannot be referenced from other compilation units.

**val adapt_filename : string -> string**

In bytecode, the identity function. In native code, replace the last extension with `.cmxs`.

## Access control

**val set_allowed_units : string list -> unit**

Set the list of compilation units that may be referenced from units that are dynamically loaded in the future to be exactly the given value.

Initially all compilation units composing the program currently running are available for reference from dynamically-linked units. `set_allowed_units` can be used to restrict access to a subset of these units, e.g. to the units that compose the API for dynamically-linked code, and prevent access to all other units, e.g. private, internal modules of the running program.

Note that `Dynlink.loadfile[35.1]` changes the allowed-units list.

**val allow_only : string list -> unit**
`allow_only` units sets the list of allowed units to be the intersection of the existing allowed units and the given list of units. As such it can never increase the set of allowed units.

`val prohibit : string list -> unit`

`prohibit` units prohibits dynamically-linked units from referencing the units named in list units by removing such units from the allowed units list. This can be used to prevent access to selected units, e.g. private, internal modules of the running program.

`val main_program_units : unit -> string list`

Return the list of compilation units that form the main program (i.e. are not dynamically linked).

`val public_dynamically_loaded_units : unit -> string list`

Return the list of compilation units that have been dynamically loaded via `loadfile` (and not via `loadfile_private`). Note that compilation units loaded dynamically cannot be unloaded.

`val all_units : unit -> string list`

Return the list of compilation units that form the main program together with those that have been dynamically loaded via `loadfile` (and not via `loadfile_private`).

`val allow_unsafe_modules : bool -> unit`

Govern whether unsafe object files are allowed to be dynamically linked. A compilation unit is 'unsafe' if it contains declarations of external functions, which can break type safety. By default, dynamic linking of unsafe object files is not allowed. In native code, this function does nothing; object files with external functions are always allowed to be dynamically linked.

## Error reporting

`type linking_error = private`

| Undefined_global of string

| Unavailable primitive of string

| Uninitialized_global of string

`type error = private`

| Not_a_bytescode_file of string

| Inconsistent_import of string

| Unavailable_unit of string

| Unsafe_file

| Linking_error of string * linking_error

| Corrupted_interface of string

| Cannot_open_dynamic_library of exn

| Library's_module_initializers_failed of exn

| Inconsistent_implementation of string

| Module_already_loaded of string

| Private_library_cannot_implement_interface of string

`exception Error of error`
Errors in dynamic linking are reported by raising the `Error` exception with a description of the error. A common case is the dynamic library not being found on the system: this is reported via `Cannot_open_dynamic_library` (the enclosed exception may be platform-specific).

`val error_message : error -> string`

Convert an error description to a printable message.
# Chapter 36

## Recently removed or moved libraries
(Graphics, Bigarray, Num, LablTk)

This chapter describes three libraries which were formerly part of the OCaml distribution (Graphics, Num, and LablTk), and a library which has now become part of OCaml's standard library, and is documented there (Bigarray).

### 36.1 The Graphics Library

Since OCaml 4.09, the `graphics` library is distributed as an external package. Its new home is:

https://github.com/ocaml/graphics

If you are using the `opam` package manager, you should install the corresponding `graphics` package:

`opam install graphics`

Before OCaml 4.09, this package simply ensures that the `graphics` library was installed by the compiler, and starting from OCaml 4.09 this package effectively provides the `graphics` library.

### 36.2 The Bigarray Library

As of OCaml 4.07, the `bigarray` library has been integrated into OCaml's standard library.

The `bigarray` functionality may now be found in the standard library `Bigarray` module, except for the `map_file` function which is now part of the Unix library. The documentation has been integrated into the documentation for the standard library.

The legacy `bigarray` library bundled with the compiler is a compatibility library with exactly the same interface as before, i.e. with `map_file` included.

We strongly recommend that you port your code to use the standard library version instead, as the changes required are minimal.

If you choose to use the compatibility library, you must link your programs as follows:

`ocamlc other options bigarray.cma other files`

`ocamlopt other options bigarray.cmxa other files`
For interactive use of the `bigarray` compatibility library, do:

```
ocamlmtop -o mytop bigarray.cma
./mytop
```

or (if dynamic linking of C libraries is supported on your platform), start `ocaml` and type `#load "bigarray.cma";;`.

## 36.3 The Num Library

The `num` library implements integer arithmetic and rational arithmetic in arbitrary precision. It was split off the core OCaml distribution starting with the 4.06.0 release, and can now be found at https://github.com/ocaml/num.

New applications that need arbitrary-precision arithmetic should use the `Zarith` library (https://github.com/ocaml/Zarith) instead of the `Num` library, and older applications that already use `Num` are encouraged to switch to `Zarith`. `Zarith` delivers much better performance than `Num` and has a nicer API.

## 36.4 The Labltk Library and OCamlBrowser

Since OCaml version 4.02, the OCamlBrowser tool and the Labltk library are distributed separately from the OCaml compiler. The project is now hosted at https://github.com/garrigue/labltk.
# Part V

## Indexes
<figure><img src="image_7.png" /></figure>
Index to the library

( * ), 529
( ** ), 531
( *. ), 531
( and* ), 883
( let* ), 883
(&&), 527, 602
(@), 537
(@@), 528
(!), 545
(!=), 526
(:=), 545
(=), 526
(==), 526
(^), 535
(~^), 547
(>), 526
(>=), 526
(<), 526
(<=), 526
(<>), 526
(-), 529
(-.), 531
(|>), 528
(||), 527, 603
(+), 529
(+.), 531
(/), 529
(/.), 531
(~-), 528
(~-.), 530
(~+), 529
(~+.), 530
(asr), 530
(land), 530
(lor), 530
(lsl), 530
(lsr), 530
(lxor), 530
(mod), 529
__FILE__, 527
__FUNCTION__, 528
__LINE_OF__, 528

__LINE__, 527
__LOC_OF__, 528
__LOC__, 527
__MODULE__, 527
__POS_OF__, 528
__POS__, 527
_exit, 1009
abs, 529, 685, 768, 771, 775, 842
abs_float, 533
absolute_path, 966
accept, 1034
access, 1019
access, 1019
access permission, 1018
acos, 532, 688
acosh, 532, 689
acquire, 913, 914
adapt_filename, 1078
add, 641, 674, 675, 677-679, 684, 752, 757, 758, 768, 770, 775, 803, 815, 820, 822, 827, 835, 841, 855, 857, 859, 871, 907, 954
add_buffer, 606
add_bytes, 606
add_channel, 607
add_char, 605
add_int16_be, 608
add_int16_le, 608
add_int16_ne, 608
add_int32_be, 608
add_int32_le, 608
add_int32_ne, 608
add_int64_be, 609
add_int64_le, 609
add_int64_ne, 609
add_int8, 608
add_iter, 855, 857, 859
add_last, 653
add_ppx_context_sig, 961
add_ppx_context_str, 961
add_seq, 607, 675, 676, 755, 757, 759, 809, 818, 821, 823, 833, 839, 872, 912, 916
add_string, 606
add_subbytes, 606
add_substitute, 606
add_substring, 606
add_symbolic_output_item, 728
add_to_list, 803, 828
add_uint16_be, 608
add_uint16_le, 608
add_uint16_ne, 608
add_uint8, 607
add_user_event, 1068
add_utf_16be Uchar, 606
add_utf_16le Uchar, 606
add_utf_8 Uchar, 605
addr_info, 1040
alarm, 746, 1029
alert, 969
alert_reporter, 968
align, 559
aligned_error_hint, 969
all_units, 1079
allocated_bytes, 745
allocation, 748
allocation_source, 747
allow_only, 1078
allow_unsafe_modules, 1079
Already_displayed_error, 970
always, 1075
and+, 883
anon Fun, 557
append, 561, 570, 654, 664, 693, 700, 786, 795, 903
append_array, 653
append_iter, 654
append_list, 654
append_seq, 654
apply, 960
Arg, 548, 555
arg, 642
arg_label, 962
argv, 936
Array, 548, 560, 692, 917
array, 522
Array0, 589
array0_of_genarray, 600
Array1, 591

array1_of_genarray, 600
Array2, 593
array2_of_genarray, 600
Array3, 596
array3_of_genarray, 600
ArrayLabels, 548, 568, 699
ascii, 638
ascii_width, 723
asin, 532, 688
asinh, 533, 689
asprintf, 732
Assert_failure, 524
Assert_failure, 193, 523
assoc, 791, 800
assoc_opt, 791, 800
assq, 791, 800
assq_opt, 791, 800
Ast_mapper, 957
Asttypes, 961
at_exit, 548, 646
atan, 532, 689
atan2, 532, 689
atanh, 533, 689
Atomic, 548, 576
atomic_flag, 962
attribute, 973
attribute_of_warning, 960
attributes, 973
auto_include_alert, 969
backend_type, 939
backtrace_slots, 864
backtrace_slots_of_raw_entry, 864
backtrace_status, 861
Bad, 559
basename, 681
batch_mode_printers, 967
before_first_spawn, 646
beginning_of_input, 887
best_tSUPERFILL, 967
big_endian, 940
Bigarray, 548, 580
Binary, 914
bind, 846, 881, 1034
binding, 999
binding_op, 983
bindings, 805, 829
bits, 875, 878
bits32, 877, 878
bits64, 877, 878
bits_of_float, 773, 778
BLAKE128, 651
BLAKE256, 651
BLAKE512, 651
blit, 562, 570, 589, 590, 592, 596, 599, 604, 611, 624, 654, 694, 701, 918, 928, 953
blit_string, 611, 624
bom, 949
Bool, 548, 602
bool, 522, 877, 878
bool_of_string, 536
bool_of_string_desc, 536
bounded_full_split, 1054
bounded_split, 1054
bounded_split_delim, 1054
bprintf, 869
Break, 944
broadcast, 645
bscanf, 888
bscanf_format, 893
bscanf_opt, 888
Bucket, 676, 678, 679
Buffer, 548, 604
Bytes, 548, 609, 917
bytes, 521, 649, 650
BytesLabels, 548, 623
c_layout, 584, 585
Callback, 548, 636
Callbacks, 1068
capacity, 659
capitalize_ascii, 614, 628, 921, 931
cardinal, 804, 829, 835, 908
case, 982
cat, 611, 625, 919, 928
catch, 860
catch_break, 944
cbrt, 687
ceil, 533, 690

change_layout, 587, 590, 592, 594, 597
channel, 649, 650, 1074
Char, 548, 637
char, 521, 584
char_of_int, 535
chdir, 938, 1020
check, 953
check_geometry, 715
check_suffix, 680
chmod, 1018
choose, 805, 829, 836, 909, 1075
choose_opt, 805, 829, 836, 909
chop_extension, 681
chop_suffix, 680
chop_suffix_opt, 680
chown, 1019
chr, 637
chroot, 1021
class_declaration, 991
class_description, 989
class_expr, 989, 999
class_expr_desc, 990
class_field, 990, 999
class_field_desc, 991
class_field_type, 991
class field kind, 991
class_info, 989
class signature, 988
class_structure, 990
class_type, 987, 999
class_type_declaration, 989
class_type_desc, 988
class_type_field, 988, 999
class_type_field_desc, 989
classify_float, 535, 687
clean, 675, 676
clear, 605, 655, 674, 675, 677-679, 751, 756, 758, 814, 820, 822, 856, 857, 859, 860, 872, 916, 954
clear_close_on_exec, 1020
clear_nonblock, 1019
clear_parser, 854
clear_symbolic_output_buffer, 727
close, 764, 849, 1011
close_box, 709
close_in, 544, 886
close_in_noerr, 544
close_noerr, 764, 849
close_out, 542
close_out_noerr, 542
close_process, 1024
close_process_full, 1024
close_process_in, 1024
close_process_out, 1024
close_stag, 720
close_tbox, 717
closed_flag, 962
closedir, 1021
code, 637
combine, 565, 573, 667, 792, 801
command, 937
compact, 745
compare, 526, 563, 571, 603, 614, 628, 637,
648, 650, 658, 665, 673, 691, 694, 702,
769, 773, 778, 786, 795, 803, 808, 827,
832, 834, 838, 844, 847, 853, 854, 858,
880, 883, 898, 907, 911, 919, 929, 950,
952
compare_and_set, 577, 578
compare_length_with, 785, 793
compare_lengths, 784, 793
Complex, 549, 641
complex32, 583
complex32_elt, 582
complex64, 583
complex64_elt, 582
compose, 735
concat, 562, 570, 611, 625, 664, 680, 693, 701,
786, 795, 903, 919, 928
concat_map, 787, 796, 903
Condition, 549, 643
conj, 641
connect, 1034
cons, 785, 794, 899
const, 735
constant, 961, 973
constant_desc, 973
constr, 999
constr_ident, 972
constructor_argument, 986
constructor_declaration, 985

contains, 613, 627, 919, 929
contains_from, 613, 627, 919, 929
contents, 604
continuation, 669, 670
Continuation already resumed, 669
continue, 669
continue_with, 671
control, 743
convert_raw_backtrace slot, 866
copy, 562, 570, 610, 624, 653, 674, 675, 693,
701, 752, 757, 758, 814, 820, 822, 845,
856, 857, 859, 860, 872, 878, 916
copy_sign, 690
copysign, 533
core_type, 971, 974, 999
core_type_desc, 976
cos, 532, 688
cosh, 532, 689
count, 955
counters, 744
Counting, 913
cpu_relax, 646
create, 585, 589, 591, 593, 596, 604, 610, 623,
645, 652, 674, 675, 692, 700, 751, 756,
758, 814, 820, 822, 840, 855, 857, 859,
871, 915, 952, 954, 1068, 1071
create-alarm, 746
create_cursor, 1069
create_float, 561, 569
create_process, 1021
create_process_env, 1022
curr, 964
current, 560
current_dir_name, 680
cursor, 1066
cycle, 900
cygwin, 939
data, 954
data_size, 812
dcr, 546, 577, 578
Deep, 669
default_alert_reporter, 968
default mapping, 959
default_report_printers, 968
default_uncaught_exception_handler,
863, 1074

default_warning_reporter, 968

delay, 1073

delayedMsg, 969

delete_alarm, 747

deprecated, 969

deprecated_script_alert, 969

descr_of_in_channel, 1013

descr_of_out_channel, 1013

development_version, 944

diff, 835, 908

Digest, 549, 648

digit_of_int, 639

digit_to_int, 639

dim, 591

dim1, 594, 597

dim2, 594, 597

dim3, 597

dims, 586

dir_handle, 1021

dir_sep, 680

direction_flag, 962

directive_argument, 998

directive_argument_desc, 998

dirname, 681

discard, 749

discontinue, 669

discontinue_with, 671

discontinue_with_backtrace, 669, 671

disjoint, 835, 908

div, 642, 684, 768, 771, 775, 842

Division_by_zero, 525

Division_by_zero, 523

DLS, 647

Doc, 966, 999

doc, 557

Domain, 549, 645

domain_of_sockaddr, 1034

dprintf, 732

drop, 790, 799, 872, 901, 915

drop_ppx_context_sig, 961

drop_ppx_context_str, 961

dropWhile, 790, 799, 902

dummy_pos, 781

dup, 1019

dup2, 1019

Dynarray, 549, 652

Dynlink, 1077

echo_eof, 964

edit_distance, 924, 934

Effect, 549, 669

effect_handler, 670

Either, 549, 671

elements, 835, 908

elt, 835, 855, 857-859, 907

Empty, 871, 915

empty, 610, 624, 803, 827, 835, 899, 907, 918, 928

enable_runtime_warnings, 945

End_of_file, 525

end_of_input, 887

End_of_file, 523

ends_with, 614, 628, 919, 929

ensure_capacity, 660

ensure_extra_capacity, 660

environment, 1006

Ephemeron, 549, 673

eprintf, 731, 869

epsilon, 686

epsilon_float, 534

eq, 946

equal, 562, 570, 603, 614, 628, 637, 648, 650, 658, 665, 673, 691, 694, 701, 756, 758, 769, 773, 778, 786, 795, 808, 819, 821, 832, 838, 844, 847, 853, 880, 882, 898, 911, 919, 929, 950, 952

erf, 689

erfc, 689

errFormatter, 725

Error, 970, 1079

error, 881, 969, 1006, 1079

error_message, 1006, 1080

error_of_exn, 970

error_of_printers, 970

error_of_printers_file, 970

error_to_failure, 881

errorf, 969

escaped, 612, 626, 637, 921, 930
establish_server, 1038
Event, 1074
event, 1075
eventlog_pause, 747
eventlog, 747
exchange, 577, 578
executable_name, 937
execv, 1007
execve, 1008
execvp, 1008
execvpe, 1008
exists, 564, 572, 612, 626, 656, 666, 696, 703,
788, 797, 808, 832, 839, 897, 911, 921,
930
exists2, 564, 572, 657, 667, 789, 798, 898
Exit, 524, 1072
exit, 548, 1072
exn, 522
exn�, 522
exn�_id, 867
exnSlot_name, 867
exp, 531, 642, 688
exp2, 688
expm1, 531, 688
expression, 971, 979, 999
expression_desc, 982
extend, 610, 624
extended_module_path, 972
extension, 681, 973
extension_constructor, 986
extension_constructorKind, 987
extension_of_error, 960
extern_flags, 810
extra_info, 944
extra_prefix, 944
Failure, 523, 525
failwith, 524
fast_sort, 566, 574, 668, 697, 704, 792, 801
fchmod, 1018
fchown, 1019
fetch_and_add, 577, 578
fiber, 670
file, 649, 650
file_desc, 1009
file_exists, 937

file, 1014
file_name, 886
file_perm, 1011
Filename, 549, 680
filename, 966
fill, 562, 570, 589, 590, 593, 596, 599, 611,
624, 693, 701, 953
filter, 656, 789, 798, 807, 831, 837, 900, 910
filter_map, 656, 787, 796, 807, 831, 838, 901,
910
filter_map_inplace, 753, 757, 759, 816, 820,
822
filteri, 790, 799, 901
finalise, 745
finalise_last, 746
finalise_release, 746
Finally_raised, 736
find, 674, 675, 677-679, 752, 757, 758, 789,
798, 806, 815, 820, 822, 830, 836, 897,
909, 954
find_all, 675, 752, 757, 759, 790, 799, 815,
820, 822, 954
find_first, 806, 830, 836, 909
find_first_opt, 806, 830, 837, 909
find_index, 565, 573, 657, 667, 696, 703, 789,
798, 897
find_last, 653, 806, 830, 837, 909
find_last_opt, 806, 830, 837, 910
find_left, 672
find_map, 565, 573, 657, 667, 696, 704, 789,
798, 897
find_mapi, 565, 573, 658, 667, 696, 704, 789,
798, 897
find_opt, 565, 573, 657, 667, 675, 696, 703,
752, 757, 758, 789, 798, 806, 815, 820,
822, 830, 836, 909, 954
findright, 672
firstchars, 1054
fit_capacity, 660
flat_map, 903
flatten, 786, 795, 971
flip, 736
Float, 549, 684
float, 522, 534, 877, 878
float16, 583
float16_elt, 581
float32, 583
float32_elt, 581
float64, 583
float64_elt, 581
float_of_bits, 773, 778
float_of_int, 534
float_of_string, 537
float_of_string_opt, 536
floor, 533, 690
flow_action, 1045
flush, 541, 850
flush_all, 541, 850
flush_input, 784
flush_queue, 1045
flush_str_formatter, 725
flush_symbolic_output_buffer, 727
fma, 684
fold, 673, 753, 757, 759, 807, 816, 820, 822, 831, 837, 846, 852, 872, 882, 910, 916, 955
fold_left, 563, 571, 612, 625, 656, 666, 695, 702, 787, 796, 896, 920, 930
fold_left2, 788, 797, 898
fold_left_map, 563, 571, 666, 787, 796
fold_lefti, 896
fold_lines, 766
fold_right, 564, 572, 612, 625, 656, 666, 695, 702, 787, 796, 920, 930
fold_right2, 788, 797
fold_unordered, 857, 859, 860
for_all, 564, 572, 612, 625, 657, 666, 673, 696, 703, 788, 797, 808, 832, 839, 896, 911, 920, 930
for_all2, 564, 572, 657, 667, 788, 797, 898
force, 171, 779
force_newline, 713
force_val, 781
Forced_twice, 902
forever, 900
fork, 1008
Format, 549, 707
format, 547, 865
format4, 522, 547
format6, 547

format_from_string, 893
format_of_string, 547
format_text, 729
formatter, 708
formatter_for_warnings, 968
formatter_of_buffer, 725
formatter_of_out_channel, 724
formatter_of_out_functions, 726
formatter_of_symbolic_output_buffer, 728
formatter_out_functions, 722
formatter_stag_functions, 723
fortran_layout, 584, 585
fpclass, 535, 687
fprintf, 730, 867
free_cursor, 1069
frexp, 533, 690
from_bytes, 812
from_channel, 782, 811, 887
from_file, 886
from_file_bin, 886
from Fun, 780
from_function, 782, 886
from_hex, 649
from_string, 782, 812, 886
from_val, 780
fst, 537, 852
fstat, 1015, 1016
fsync, 1011
ftruncate, 1013, 1015
full_init, 875
full_int, 875, 878
full_major, 745
full_split, 1054
Fun, 549, 735
function_body, 983
function_param, 983
function_param_desc, 983
functor_parameter, 992
Gc, 549, 740
Genarray, 585
genarray_of_array0, 600
genarray_of_array1, 600
genarray_of_array2, 600
genarray_of_array3, 600
geometry, 715
get, 560, 568, 577, 587, 590, 592, 595, 598,
609, 623, 648, 653, 664, 692, 699, 744,
846, 918, 928, 953

get_backtrace, 861

get_callstack, 670, 671, 863

get cookie, 961

get_copy, 953

get_current, 1066

get_ellipsis_text, 718

get_err_format, 725

get_error, 881

get_formatter_out_functions, 723

get_formatter_output_functions, 721

get_formatter_stag_functions, 724

get_geometry, 716

get_id, 646

get_int16_be, 619, 633, 925, 935

get_int16_le, 619, 633, 925, 935

get_int16_ne, 619, 633, 925, 935

get_int32_be, 619, 633, 926, 936

get_int32_le, 619, 633, 926, 936

get_int32_ne, 619, 633, 926, 935

get_int64_be, 620, 634, 926, 936

get_int64_le, 620, 634, 926, 936

get_int64_ne, 620, 633, 926, 936

get_int8, 619, 632, 925, 935

get_last, 653

get_left, 672

get margin, 714

get_markos, 720

get_max boxes, 717

get_max_elt, 857, 859

get_max indent, 715

get_min_elt, 855, 859

get_minor_free, 745

get_ok, 881

get_ok', 881

get pos info, 964

get_printos, 720

get_raw_backtrace, 862

get_raw_backtrace_next slot, 866

get_raw_backtrace slot, 866

get right, 672

get state, 879

get_std_format, 725

get stdbuf, 725

get_str_format, 725

get_symbolic_output_buffer, 727

get_temp_dir_name, 682

get_uint16_be, 619, 633, 925, 935

get_uint16_le, 619, 633, 925, 935

get_uint16_ne, 619, 633, 925, 935

get_uint8, 619, 632, 925, 935

get_utf_16be_uchar, 618, 631, 923, 933

get_utf_16le_uchar, 618, 632, 924, 933

get_utf_8_uchar, 617, 631, 923, 933

get_value, 914

getaddrinfo, 1041

getaddrinfo_option, 1041

getcwd, 938, 1021

getegid, 1031

getenv, 937, 1006

getenv_opt, 937

geteuid, 1030

getgid, 1031

getgrgid, 1032

getgrnam, 1032

getgroups, 1031

gethostbyaddr, 1039

gethostbyname, 1039

gethostname, 1039

getitimer, 1030

getlogin, 1032

getnameinfo, 1042

getnameinfo_option, 1042

getpeername, 1035

getpid, 1009

getppid, 1009

getprotobyname, 1040

getprotobynumber, 1040

getpwnam, 1032

getpwuid, 1032

getservbyname, 1040

getservbyport, 1040

getsockname, 1035

getsockopt, 1037

getsockopt_error, 1038

getsockopt_float, 1038
getsockopt_int, 1038
getsockopt_optint, 1038
gettimeofday, 1029
getuid, 1030
global_replace, 1053
global_substitute, 1053
gmtime, 1029
group, 902
group_beginning, 1052
group_end, 1053
group_entry, 1032
guard, 1075
handle_unix_error, 1006
handler, 670
has_symlink, 1025
hash, 603, 641, 692, 756, 760, 770, 774, 778, 819, 823, 845, 926, 935, 950
hash_length, 650
hash_param, 760, 824
HashedType, 756, 819
Hashtbl, 549, 750, 813
hd, 785, 794
header_size, 812
Help, 559
hexlesstoint, 639
highlight_terminfo, 966
host_entry, 1039
hypot, 532, 689
i, 641
Iarray, 549, 664
ibprintf, 870
Id, 947
id, 646, 735, 845, 1072
ifprintf, 732, 869
ignore, 535
ikbprintf, 870
ikfprintf, 733, 870
Immediate, 946
Immediate64, 945
implementation, 971
In_channel, 549, 762
in_channel, 537, 885
in_channel_length, 544, 545
in_channel_of_descr, 1012

in_file, 963
include声明, 995
include_description, 995
include, 995
incr, 546, 577, 578
index, 612, 626, 922, 932
index_from, 613, 626, 922, 932
index_from_opt, 613, 627, 922, 932
index_opt, 612, 626, 922, 932
inet6_addr_any, 1033
inet6_addr_loopback, 1033
inet_addr, 1032
inet_addr_any, 1033
inet_addr_loopback, 1033
inet_addr_of_string, 1032
infinity, 534, 685
init, 561, 569, 586, 590, 591, 594, 597, 610, 623, 652, 664, 693, 700, 786, 794, 875, 879, 918, 927, 963
init_matrix, 561, 569, 693, 700
initgroups, 1031
injectivity, 962
input, 543, 649, 650, 765
input_all, 765
input_bigarray, 765
input_binary_int, 544
inputbyte, 544, 764
input_char, 543, 764
input_lexbuf, 964
input_line, 543, 764
input_lines, 765
input_name, 964
input_phrase_buffer, 964
input_value, 544
Int, 549, 767
int, 521, 583, 875, 878, 1067
int16 signed, 583
int16 signed_elt, 582
int16 unsigned, 583
int16 unsigned_elt, 582
Int32, 550, 770
int32, 522, 584, 876, 878
int32_elt, 582
int32_in_range, 876, 878
Int64, 550, 774
int64, 522, 584, 877, 878
int64_elt, 582
int64_in_range, 877, 878
int8 signed, 583
int8 signed_elt, 582
int8 unsigned, 583
int8 unsigned_elt, 582
int_elt, 582
int_in_range, 876, 878
int_of_char, 535
int_of_float, 534
int_of_string, 536
int_of_string_opt, 536
int_size, 939
inter, 835, 908
interactive, 938
interface, 971
interleave, 904
interval_timer, 1030
interval_timer_status, 1030
ints, 906
inv, 642
invalid_arg, 524
Invalid_argument, 525
Invalid_argument, 523
io_buffer_size, 938
is_alphanumeric, 638
is_binary_mode, 767, 851
isblank, 639
is_buffered, 851
is_char, 949
is_control, 639
is_digest, 639
is_directory, 937
is_empty, 653, 785, 793, 808, 832, 838, 855, 857, 859, 872, 895, 911, 916
is_error, 882
is_finite, 686
is_graphic, 639
is_hex时代的, 639
is_implicit, 680
is_inet6_addr, 1033
is_infinite, 686
is inline, 865
is_integer, 686

is_left, 672
is_letter, 638
is_lower, 638
is_main_domain, 646
is_nan, 686
is_native, 1077
is_none, 847, 963
is_ok, 882
is_print, 639
is RaisE, 865
is_randomized, 754, 817
is COGLIGAR, 937
is_relative, 680
is right, 672
is_some, 847
is_lower, 638
is_val, 780
is_valid, 638, 949
is_valid_utf_16be, 618, 632, 923, 933
is_valid_utf_16le, 618, 632, 924, 933
is_valid_utf_8, 617, 631, 923, 933
is white, 638
isatty, 767, 851, 1015
iter, 563, 571, 611, 625, 655, 665, 673, 694, 702, 753, 757, 759, 787, 796, 806, 815, 820, 822, 830, 837, 846, 852, 872, 882, 896, 910, 916, 922, 931, 954
iter2, 564, 572, 666, 695, 703, 788, 797, 897
iter_error, 882
iter_unordered, 856, 857, 859, 860
iterate, 900
iteri, 563, 571, 611, 625, 655, 665, 694, 702, 787, 796, 896, 922, 931
join, 646, 846, 882, 1073
K1, 676
K2, 677
kasprintf, 733
kbprintf, 870
kdprintf, 732
key, 557, 647, 674, 675, 756, 758, 803, 820, 822, 827
kfprintf, 732, 870
kill, 1027
kind, 582, 587, 590, 592, 594, 597
kind_size_in_bytes, 584
Kn, 678
kprintf, 870
kscanf, 892
ksprintf, 733, 870
ksscanf, 892
label, 962
label_declaration, 985
LargeFile, 545, 1015
last, 971
last_chars, 1055
layout, 585, 587, 590, 592, 594, 597
Lazy, 550, 779
Lazy (module), 171
lazy_t, 522
ldexp, 533, 691
left, 672
length, 560, 568, 605, 609, 623, 653, 664, 675, 677-679, 692, 699, 753, 757, 759, 766, 784, 793, 816, 820, 822, 850, 855, 857, 859, 872, 896, 916, 918, 928, 952
let+, 883
letop, 983
lexbuf, 782
lexeme, 783
lexeme_char, 783
lexeme_end, 783
lexeme_end_p, 784
lexeme_start, 783
lexeme_start_p, 783
Lexing, 550, 781
lifecycle, 1066
lifecycle_name, 1066
link, 1018
linking_error, 1079
List, 550, 784, 917
list, 522
listen, 1034
ListLabels, 550, 793
lnot, 530
loadfile, 1077
loadfile_private, 1078
Loc, 577
loc, 962, 964, 966

localtime, 1029
Location, 963
location, 864, 865
location_stack, 973
lock, 840
lock_command, 1026
lockf, 1026
locs, 966
log, 531, 642, 688
log10, 531, 688
log1p, 531, 688
log2, 688
logand, 603, 768, 771, 776, 843
lognot, 768, 772, 776, 843
logor, 603, 768, 772, 776, 843
logxor, 603, 768, 772, 776, 843
Longident, 970
longident, 971, 999
lower_hex时代的int, 640
lowercase, 640
lowercase CHAR, 614, 627, 640, 921, 931
lseek, 1013, 1015
lstat, 1015, 1016
main_program_units, 1079
major, 744
major_slice, 744
Make, 676, 677, 679, 758, 809, 821, 833, 840, 912, 946, 955
make, 561, 569, 576, 610, 623, 652, 676-679, 692, 700, 852, 878, 913, 914, 918, 927, 947
make_contended, 576
make_formatter, 726
make_matrix, 561, 569, 693, 700
makealle, 878
make_symbolic_output_buffer, 727
make_synchronized_formatter, 726
MakeMax, 858
MakeMaxPoly, 860
MakeMin, 857
MakeMinPoly, 859
MakeSeeded, 676, 677, 679, 759, 823
Map, 550, 802, 826
map, 563, 571, 611, 625, 656, 666, 672, 695,
702, 780, 787, 796, 807, 831, 837, 846,
852, 882, 900, 910, 920, 930
map2, 564, 572, 666, 695, 703, 788, 797, 903
map_error, 882
map_file, 1017
map_from_array, 698, 705
map_fst, 852
map_inplace, 563, 571, 695, 702
map_left, 672
map_opt, 960
map_product, 904
map_right, 672
map_snd, 852
map_to_array, 698, 705
map_val, 780
mapi, 563, 571, 611, 625, 656, 666, 695, 702,
787, 796, 807, 831, 900, 920, 930
mapi_inplace, 563, 571, 695, 702
mapper, 959
 Marshal, 550, 810
match_beginning, 1052
match_end, 1052
Match_failure, 524
match_with, 670
matched_group, 1052
matched_string, 1051
Match_failure, 177, 180, 183, 523
Max, 857
max, 526, 638, 691, 769, 774, 778, 845, 880, 949
max_array_length, 940
max_bind, 805, 829
max_bind_opt, 805, 829
max_elt, 836, 857, 859, 908
max_elt_opt, 836, 909
max_float, 534, 686
max_floatarray_length, 940
max_int, 529, 768, 771, 776, 842
max_num, 691
max_string_length, 940
max_utf_8_decode_length, 951
MaxPoly, 859
MD5, 651
mem, 565, 573, 657, 667, 675, 696, 703, 752,
757, 759, 789, 798, 808, 815, 820, 822,
832, 838, 911, 954

mem Assoc, 791, 800
membind, 791, 800
mem_ieee, 696, 703
memoize, 902
Memprof, 747
memq, 565, 573, 657, 667, 789, 798
merge, 792, 802, 804, 828, 954
Min, 855
min, 526, 638, 691, 769, 774, 778, 845, 880, 949
min_bind, 805, 829
min_bind_opt, 805, 829
min_elt, 836, 855, 859, 908
min_elt_opt, 836, 908
min_float, 534, 686
min_int, 529, 768, 771, 776, 842
min_max, 691
min_max_num, 692
min_num, 691
minor, 744
minor_words, 744
MinPoly, 858
minus_one, 684, 767, 770, 775, 841
mkdir, 938, 1020
mkfifo, 1021
mkloc, 964
mknoloc, 964
mktime, 1029
mod_float, 533
modf, 533, 691
module_bind, 998
module_declaration, 993
module_expr, 971, 995, 999
module_expr_desc, 996
module_substitution, 994
module_type, 971, 992, 999
module_type_declaration, 994
module_type_desc, 992
MoreLabels, 550, 813
msg, 966
msg_flag, 1035
mul, 642, 684, 768, 771, 775, 841
mutable_flag, 962
Mutex, 550, 840
name, 865, 1068
name_info, 1041
name_of_input, 887
nan, 534, 685
nativebits, 877, 878
Nativeint, 550, 841
nativeint, 522, 584, 876, 878
nativeint_elt, 582
nativeint_in_range, 876, 878
neg, 641, 684, 768, 770, 775, 841
neg_infinity, 534, 685
negate, 736
new_channel, 1074
new_key, 647
new_line, 784
next_after, 690
nice, 1009
node, 895
nominal_exp, 999
Non_immediate, 946
none, 846, 963
norm, 642
norm2, 642
not, 527, 602
Not_found, 525
Not_found, 523
nth, 605, 785, 794
nth_dim, 586
nth_opt, 785, 794
null, 681
null_tracking, 748
num_dims, 586
Obj, 550
object_field, 977
object_field_desc, 977
Ocaml_operators, 955
ocaml_release, 945
ocaml_release_info, 945
ocaml_version, 944
of_array, 593, 596, 599, 658, 665, 856, 857, 859, 860
of_binary_string, 879
of_bytes, 918, 928
of_char, 950
of_dispenser, 906

of_float, 769, 772, 777, 843
of_hex, 649, 651
of_int, 686, 772, 776, 843, 949
of_int32, 777, 844
of_iter, 856, 857, 859, 860
of_list, 562, 570, 658, 665, 694, 701, 809, 833, 839, 856, 857, 859, 860, 912
of_nativeint, 777
of_seq, 567, 575, 607, 617, 631, 659, 668, 675, 676, 698, 705, 755, 757, 759, 793, 802, 809, 818, 821, 823, 833, 839, 873, 912, 916, 923, 933
of_string, 610, 624, 686, 773, 777, 844
of_string_opt, 687, 773, 777, 844
of_value, 591
ok, 881
once, 902
one, 641, 684, 767, 770, 774, 841
Oo, 550, 845
opaque_identity, 945
open_bin, 763, 848
open_box, 709
open_connection, 1038
open_declaration, 994
open_description, 994
open_flag, 540, 763, 848, 1010
open_gen, 763, 848
open_hbox, 709
open_hovbox, 710
open_hvbox, 710
open_in, 543, 886
open_in_bin, 543, 886
open_in_gen, 543
open, 994
open_out, 540
open_out_bin, 541
open_out_gen, 541
open_process, 1022
open_process_args, 1023
open_process_args_full, 1023
open_process_args_in, 1023
open_process_args_out, 1023
open_process_full, 1022
open_process_in, 1022
open_process_out, 1022
open_stag, 720
open_tbox, 717
open_temp_file, 682
open_text, 763, 848
open_vbox, 709
opendir, 1021
openfile, 1011
Option, 550, 846
option, 522
OrderedPolyType, 858
OrderedType, 802, 827, 834, 854, 907
os_type, 939
Out_channel, 550, 847
out_channel, 537
out_channel_length, 542, 545
out_channel_of descr, 1012
Out_of_memory, 525
Out_of_memory, 523
output, 541, 649, 650, 849
output_bigarray, 850
output_binary_int, 541
output_buffer, 605
output_byte, 541, 849
output_bytes, 541, 849
output_char, 541, 849
output_string, 541, 849
output_substring, 541, 850
output_value, 542
over_max boxes, 717
override_flag, 962
package_type, 976
Pair, 550, 852
parent_dir_name, 680
Parse, 971
parse, 557, 971
parse_and_extend_argv_dynamic, 559
parse_argv, 558
parse_argv_dynamic, 559
parse_dynamic, 558
Parse_error, 854
parse_extend, 559
Parsetree, 973
Parsing, 550, 853
partition, 790, 799, 807, 832, 838, 905, 911

partition_map, 790, 799, 905
passwd_entry, 1031
path, 1069
pattern, 971, 977, 999
pattern_desc, 979
pause, 1027, 1069
payload, 974, 999
peek, 871
peek_opt, 871
perform, 669
phys_equal, 880
pi, 686
pipe, 1021
polar, 642
poll, 1075
pollActions, 940
pop, 871, 915
pop_last, 655
pop_last_opt, 655
pop_max, 857, 859
pop_min, 856, 859
pop_opt, 915
pos, 766, 850
pos_in, 544, 545
pos_out, 542, 545
position, 781
pow, 642, 687
pp_close_box, 709
pp_close_stag, 720
pp_close_tbox, 717
pp_force_newline, 713
pp_get_ellipse_text, 718
pp_get_formatter_out_functions, 723
pp_get_formatter_output_functions, 721
pp_get_formatter_stag_functions, 724
pp_get_geometry, 716
pp_get margin, 714
pp_get_markos, 720
pp_get_max boxes, 717
pp_get_max indent, 715
pp_get_printos, 720
pp_infinity, 714
pp_open_box, 709
pp_open_hbox, 709
pp_open_hovbox, 710
pp_open_hvbox, 710
pp_open_stag, 720
pp_open_tbox, 717
pp_open_vbox, 709
pp_over_max boxes, 717
pp_print_array, 728
pp_print_as, 710
pp_print_bool, 711
pp_print_break, 712
pp_print_bytes, 710
pp_print_char, 711
pp_print_custom break, 712
pp_print cut, 712
pp_print_either, 730
pp_print_float, 711
pp_print_flush, 713
pp_print_if_newline, 713
pp_print_int, 711
pp_print_iter, 728
pp_print_list, 728
pp_print_newline, 714
pp_print_nothing, 711
pp_print_option, 729
pp_print_result, 729
pp_print_seq, 728
pp_print_space, 712
pp_print_string, 710
pp_print_substring, 710
pp_print_substring_as, 711
pp_print_tab, 717
pp_print_tbreak, 718
pp_print_text, 729
pp_safe_set_geometry, 716
pp_set_ellipsis_text, 718
pp_set_formatter out_channel, 720
pp_set_formatter out_functions, 722
pp_set_formatter output functions, 721
pp_set_formatter_stag functions, 723
pp_set_geometry, 716
pp_setmargin, 714
pp_set_mark tags, 720
pp_set_max boxes, 716
pp_set_max indent, 714
pp_set_print tags, 720
pp_set_tab, 717

pp_setelo tags, 720
pp_update_geometry, 716
Pprintast, 998
Pqueue, 549, 854
pred, 529, 685, 768, 771, 775, 842, 949
prerr_alert, 969
prerr_bytes, 539
prerr_char, 539
prerr endline, 539
prerr float, 539
prerr int, 539
prerr newline, 539
prerr string, 539
prerr warning, 968
print, 860
printAlert, 969
print_as, 710
printbacktrace, 861
print bool, 711
print break, 712
print_bytes, 538, 710
print_char, 538, 711
print cut, 712
print endline, 538
print filename, 966
print float, 538, 711
print flush, 713
print_if_newline, 713
print int, 538, 711
print loc, 966
print locs, 966
print_newline, 538, 714
print_raw_backtrace, 863
print_report, 967
print_space, 712
print_stat, 745
print_string, 538, 710
print_substring, 710
print_substring_as, 711
print_tab, 717
print_tbreak, 718
print warning, 968
Printexc, 550, 860
ntf, 550, 867
printf, 731, 869
private_flag, 962
process_full_pid, 1024
process_in_pid, 1023
process_out_pid, 1024
process_pid, 1024
process_status, 1007
process_times, 1028
product, 882, 904
prohibit, 1079
protect, 736, 841
protocol_entry, 1039
provably_equal, 947
public_dynamically_loaded_units, 1079
push, 871, 915
putenv, 1007

query, 676–678
Queue, 550, 871
quick_stat, 744
quiet_nan, 685
quote, 683, 1050
quote_command, 683
quoted_filename, 966

raise, 524
raise_errorf, 970
raise_notrace, 524
raise_with_backtrace, 863
ramp_down, 750
ramp_up, 750
Random, 550, 875
randomize, 753, 816
raw_backtrace, 862
raw_backtrace_entries, 862
raw_backtrace_entry, 862
raw_backtrace_length, 866
raw_backtrace�Slot, 866
raw_backtrace_to_string, 863
rcontains_from, 614, 627, 919, 929
read, 1011
read_arg, 560
read_arg0, 560
read_bigarray, 1011
read_float, 540
read_float_opt, 540
read_int, 539

read_int_opt, 539
read_line, 539
read_poll, 1069
readdir, 938, 1021
readlink, 1025
really_input, 543, 765
really_input_bigarray, 766
really_input_string, 544, 764
realpath, 1018
rebuild, 754, 817
rec_flag, 962
receive, 1075
recommended_domain_count, 646
record_backtrace, 861
recv, 1035
recvfrom, 1035
ref, 545
regexp, 1049
regexp_case_fo, 1050
regexp_string, 1050
regexp_string_case_fo, 1051
register, 636, 960, 1067
register_error_of_exn, 970
register_exception, 637
register_function, 960
register_print, 861
release, 913, 914
rem, 685, 768, 771, 775, 842
remove, 674, 675, 677–679, 752, 757, 758, 804,
815, 820, 822, 828, 835, 908, 937, 954
remove, 791, 800
remove_assq, 791, 801
remove_extension, 681
remove_last, 655
remove_max, 857, 860
remove_min, 856, 859
rename, 937, 1018
rep, 949
repeat, 900
replace, 675, 752, 757, 759, 815, 820, 822
replace_first, 1053
replace_match, 1053
replace_seq, 675, 676, 755, 757, 759, 818,
821, 823
report, 967
report_alert, 968
report_exception, 970
reportASYM, 966
report_printers, 967
report_warning, 968
Repr, 551, 880
repr, 946
reset, 605, 661, 674, 675, 752, 756, 758, 814,
820, 822, 964
reshape, 600
reshape_0, 601
reshape_1, 601
reshape_2, 601
reshape_3, 601
Result, 551, 881
result, 546
resume, 1069
retract, 673, 882
return, 899
rev, 785, 794
rev_append, 786, 795
rev_map, 787, 796
rev_map2, 788, 797
rewinddir, 1021
rewrite_absolute_path, 964
rewrite_find_all_existing_dirs, 965
rewrite_find_first_existing, 965
rhs_end, 853
rhs_end_pos, 853
rhs_interval, 964
rhs_loc, 964
rhs_start, 853
rhs_start_pos, 853
right, 672
rindex, 612, 626, 923, 932
rindex_from, 613, 627, 922, 932
rindex_from_opt, 613, 627, 922, 932
rindex_opt, 612, 626, 923, 932
rmdir, 938, 1020
round, 690
row_field, 976
row_field_desc, 977
run_main, 960
runtime_counter, 1060
runtime_counter_name, 1066

Runtime_events, 1057
runtime_parameters, 940
runtime_phase, 1065
runtime_phase_name, 1066
runtime_variant, 940
runtime_warnings_enabled, 945
S, 650, 674, 756, 803, 820, 827, 834, 907, 953
safe_set_geometry, 716
same, 971
scan, 901
Scan_failure, 887
scanbuf, 885
Scanf, 551, 884
scanf, 892
scanf_opt, 892
scanner, 887
scanner_opt, 887
Scanning, 885
search_backward, 1051
search_forward, 1051
seeded_hash, 603, 641, 692, 758, 760, 770,
774, 778, 821, 824, 845, 926, 936, 950
seeded_hash_param, 760, 824
SeededHashedType, 758, 821
SeededS, 675, 758, 822
seek, 766, 850
seek_command, 1013
seek_in, 544, 545
seek_out, 542, 545
select, 1025, 1073, 1075
self, 646, 1072
self_index, 647
self_init, 875
Semaphore, 551, 913
send, 1035, 1075
send_substring, 1035
sendto, 1036
sendto_substring, 1036
separate_new_message, 966
Seq, 551, 893
service_entry, 1039
Set, 551, 833, 906
set, 560, 569, 577, 587, 590, 592, 595, 598,
609, 623, 648, 653, 692, 700, 744, 952
set_allowed_units, 1078
set_binary_mode, 766, 851
set_binary_mode_in, 545
set_binary_mode_out, 542
set_buffered, 851
set_capacity, 661
set_close_on_exec, 1019
set cookie, 961
set_current_thread_name, 1072
set_ellipsis_text, 718
set_filename, 783
set_formatter_out_channel, 721
set_formatter_out_functions, 722
set_formatter_output_functions, 721
set_formatter_stag_functions, 723
set_geometry, 716
set_int16_be, 621, 634
set_int16_le, 621, 635
set_int16_ne, 620, 634
set_int32_be, 621, 635
set_int32_le, 621, 635
set_int32_ne, 621, 635
set_int64_be, 621, 635
set_int64_le, 621, 635
set_int64_ne, 621, 635
set_int8, 620, 634
set margin, 714
set_markelp, 720
set_max�, 716
set_max_mind, 714
set nonblock, 1019
set position, 783
set printp, 720
set signal, 941
set state, 879
set_m, 717
set_m, 720
set_temp_dir_name, 683
set_trace, 854
set uint16 be, 620, 634
set uint16 le, 620, 634
set uint16 ne, 620, 634
set uint8, 620, 634
set uncaught_exception_handler, 863,
1074

set_utf_16be_uchar, 618, 631
set_utf_16le_uchar, 618, 632
set_utf_8_uchar, 617, 631
setattr when, 1044
setgid, 1031
setgroups, 1031
setitimer, 1030
setsid, 1045
setsockopt, 1037
setsockopt_float, 1038
setsockopt_int, 1038
setsockopt_optint, 1038
setuid, 1031
Shallow, 670
shift left, 769, 772, 776, 843
shift right, 769, 772, 776, 843
shift right logical, 769, 772, 776, 843
show filename, 966
shuffle, 566, 574, 697, 704
shutdown, 1035
shutdown command, 1035
shutdown_connection, 1038
sigabrt, 941
sigalrm, 941
sigbus, 942
sigchld, 942
sigcont, 942
sigfpe, 941
sighup, 941
sigill, 941
sigint, 941
sigio, 943
sigkill, 941
sigmask, 1074
sign bit, 690
signal, 645, 940, 941
signal behavior, 941
signal of int, 944
signal to int, 944
signal to string, 943
signaling nan, 685
signature, 992, 999
signature item, 992, 999
signature item desc, 993
sigpending, 1027
sigpipe, 942

sigpoll, 943

sigprocmask, 1027

sigprocmask_command, 1027

sigprof, 942

sigquit, 942

sigsegv, 942

sigstop, 942

sigsuspend, 1027

sigsys, 943

sigterm, 942

sigtrap, 943

sigtstp, 942

sigttin, 942

sigttou, 942

sigurg, 943

sigusr1, 942

sigusr2, 942

sigvtalrm, 942

sigwait, 1027

sigwinch, 943

sigxcpu, 943

sigxfsz, 943

simple_module_path, 972

sin, 532, 688

single_write, 1011

single_write_bigarray, 1012

single_write_substring, 1012

singleton, 785, 794, 804, 828, 835, 899, 907

sinh, 532, 689

size, 842

size_in_bytes, 587, 590, 592, 594, 597

sleep, 1029

sleepf, 1029

slice, 592

slice_left, 588, 595

slice_left_1, 598

slice_left_2, 599

slice_right, 589, 595

slice_right_1, 598

slice_right_2, 599

Slot, 865

snd, 537, 852

sockaddr, 1034

socket, 1034

socket_bool_option, 1036

socket_domain, 1033

socket_float_option, 1037

socket_int_option, 1037

socket_optint_option, 1037

socket_type, 1034

socketpair, 1034

some, 846

sort, 566, 574, 668, 696, 704, 792, 801

sort_uniq, 792, 801

sorted_merge, 904

space_format, 999

span, 1067

spawn, 645

spec, 557

spellcheck, 924, 934

split, 565, 573, 667, 792, 801, 808, 832, 838, 878, 879, 905, 911, 1053

split_delim, 1054

split_on_char, 616, 630, 920, 929

split_result, 1054

sprintf, 731, 869

sqrt, 531, 642, 687

sscanf, 892

sscanf_format, 893

sscanf_option, 892

stable_sort, 566, 574, 668, 697, 704, 792, 801

Stack, 551, 915

Stack_overflow, 525

Stack_overflow, 523

stag, 718

start, 748, 1069

starts_with, 614, 628, 919, 929

stat, 741, 743, 1015, 1016

State, 878

statistics, 754, 817

stats, 675, 754, 757, 759, 817, 820, 822, 955, 1015, 1016

stats_alive, 675, 676

std_format, 725

stderr, 538, 848, 1010

stderr, 538, 848, 1010

stdin, 538, 763, 885, 1009

StdLabels, 551, 917

Stdlib, 524
stdout, 538, 848, 1009
stop, 749
Str, 1049
str_formatter, 725
String, 551, 917
string, 522, 648, 650
string_after, 1054
string_before, 1054
string_match, 1051
string_of_allocation_source, 747
string_of_bool, 536
string_of_expression, 999
string_of_float, 536
string_of_format, 547
string_of_inet_addr, 1032
string_of_int, 536
string_of_label, 962
string_of_structure, 999
string_partial_match, 1051
StringLabels, 551, 927
structure, 996, 999
structure_item, 996, 999
structure_item_desc, 997
sub, 562, 570, 592, 604, 610, 624, 642, 664,
684, 693, 701, 768, 771, 775, 841, 920,
929
sub_left, 588, 595, 598
sub_right, 588, 595, 598
sub_string, 610, 624
subbytes, 649, 650
subset, 839, 911
substitute_first, 1053
substring, 649, 650
succ, 529, 685, 768, 771, 775, 842, 949
suspended_collection_work, 750
swap, 852
symbol_end, 853
symbol_end_pos, 853
symbol_gloc, 964
symbol_rloc, 964
symbol_start, 853
symbol_start_pos, 853
symbolic_output_buffer, 727
symbolic_output_item, 727
symlink, 1024

sync, 1075
synchronized_formatter_of_out_channel,
724
Syntax, 883
Sys, 551, 936
Sys blocked io, 525
Sys_error, 525
Sys blocked io, 524
Sys_error, 523
system, 1008
t, 560, 568, 576, 577, 585, 589, 591, 593, 596,
602, 604, 614, 628, 637, 641, 644, 645,
648, 650, 652, 664, 669, 672, 674-679,
691, 692, 699, 747, 751, 756, 758, 763,
767, 773, 778, 779, 784, 793, 803, 813,
819-822, 827, 834, 835, 840, 844, 846,
847, 852, 854, 855, 857-860, 865, 871,
878, 881, 895, 907, 913-915, 918, 927,
946, 947, 949, 951, 952, 954, 963, 971,
1066-1068, 1071
tag, 719, 1067, 1068
take, 790, 799, 871, 901
take_opt, 871
take while, 790, 799, 902
tan, 532, 688
tanh, 532, 689
tcdrain, 1045
tcflow, 1045
tcflush, 1045
tcgetattr, 1044
tcsendbreak, 1045
tcsetattr, 1044
temp_dir, 682
temp_file, 681
terminal_io, 1044
terminfo toplevel printer, 967
Thread, 1071
time, 938, 1028
times, 1029
Timestamp, 1066
tl, 785, 794
tm, 1028
to_array, 658, 665
to_binary_string, 879
to_buffer, 811
to_bytes, 604, 811, 918, 928
to_channel, 810
to_char, 950
to_dispenser, 906
to_float, 603, 769, 772, 777, 844
to_hex, 649, 651
to_int, 603, 686, 772, 776, 843, 949
to_int32, 777, 844
to_int64, 1066
to_list, 562, 570, 658, 665, 694, 701, 809, 833, 839, 847, 883, 912
to_nativeint, 777
to_option, 883
to_result, 847
to_rev_seq, 809, 833, 839, 912
to_seq, 567, 575, 607, 617, 631, 659, 668, 697, 705, 755, 757, 759, 793, 802, 809, 818, 820, 822, 833, 839, 847, 872, 883, 912, 916, 923, 933
to_seq_from, 809, 833, 839, 912
to_seq_keys, 755, 757, 759, 818, 820, 823
to_seq_reentrant, 659
to_seq_rev, 659
to_seq_rev_reentrant, 659
to_seq_values, 755, 757, 759, 818, 821, 823
to_seqi, 567, 575, 607, 617, 631, 668, 697, 705, 923, 933
to_string, 603, 610, 624, 687, 769, 773, 777, 811, 844, 860, 952
to_string_default, 860
tool_name, 960
top, 872, 915
top_opt, 916
top_phrase, 999
toplevel_directive, 998
toplevel_phrase, 971, 998, 999
total_size, 812
tracker, 748
transfer, 872
transpose, 902
trim, 612, 626, 921, 930
trunc, 690
truncate, 534, 605, 655, 1013, 1015
try_acquire, 913, 914

try_lock, 840
try_with, 670
Type, 551, 946, 1066
type_constraint, 984
type_declaration, 984
type_exception, 986
type_extension, 986
type_ident, 972
typekind, 985
tyvar, 999
tyvar_of_name, 999
Uchar, 551, 948
uid, 947
umask, 1019
uncapitalizeucle, 614, 628, 921, 931
uncons, 895
Undefined, 779
Undefined_recursive_module, 525
Undefined_recursive_module, 524
unescaped, 893
unflatten, 971
unfold, 899
Unhandled, 669
union, 804, 828, 835, 908
Unit, 551, 951
unit, 522, 1066
Unix, 1001
unix, 939
Unix_error, 1006
UnixLabels (module), 1045
unlink, 1017
unlock, 840
unsafeenvironment, 1006
unsafe_get, 593, 596, 599
unsafe_getenv, 1006
unsafe_of_string, 616, 630
unsafe_set, 593, 596, 599
unsafe_to_iarray, 661
unsafe_to_string, 615, 628
unsigned compare, 773, 778, 844
unsigned_div, 771, 775, 842
unsignedrem, 771, 775, 842
unsigned_to_int, 772, 776, 843
unzip, 905
update, 803, 828
update_geometry, 716
upper_hex时代的int, 640
uppercase, 640
uppercase_ascii, 614, 627, 640, 921, 931
usage, 559
usage_msg, 557
usage_string, 559
use_file, 971
use_printers, 862
User, 1067
utf_16_bytes_length, 951
utf_8_bytes_length, 951
utf_8_decode_length_of_bytes, 951
utf_8_scalar_length, 723
utf_decode, 950, 951
utf_decode_valid, 951
utf_decode_is_valid, 950
utf_decode_length, 950
utf_decode_uchar, 950
utimes, 1029

val_ident, 972
value, 846, 881
value_bind, 998
value_constraint, 998
value_description, 984
variance, 962
virtual_flag, 962

wait, 645, 1008
wait_flag, 1007
wait_pid, 1073
wait_signal, 1074
wait_timed_read, 1073
wait_timed_write, 1073
waitpid, 1008
warning_reporter, 968
Weak, 551, 952
win32, 939
with_constraint, 995
with_open_bin, 764, 849
with_open_gen, 764, 849
with_open_text, 764, 849
with_POSITIONS, 783
word_size, 939

wrap, 1075
wrap_abort, 1075
write, 1011, 1067
write_arg, 560
write_arg0, 560
write_bigarray, 1011
write_substring, 1012
yield, 1073
zero, 641, 684, 767, 770, 774, 841
zip, 903
Index of keywords

and, 173, 195, 200, 204, 205, 210, 216, 221
as, 162, 163, 166, 167, 200, 203
asr, 160, 174, 188
assert, 193

begin, 165, 173, 175

class, 204, 205, 208, 210, 211
constraint, 195, 198, 200, 204

do, see while, for
done, see while, for
downto, see for

else, see if
end, 165, 173, 175, 198, 200, 205, 206, 210
exception, 198, 205, 207, 210, 211
external, 205, 207, 210, 211

false, 165
for, 173, 184
fun, 173, 174, 178, 200, 220
function, 173, 174, 177
functor, 205, 209, 210, 212

if, 173, 174, 182
in, see let
include, 205, 209, 210, 212, 224
inherit, 198, 200, 203
 initializ er, 200, 204

land, 160, 174, 188
lazy, 171, 173, 194
let, 173, 174, 180, 194, 200, 210, 211
lor, 160, 174, 188
lsl, 160, 174, 188
lsr, 160, 174, 188
lxor, 160, 174, 188

match, 173, 174, 182, 230
method, 198, 200, 203, 204
mod, 160, 174, 188
module, 194, 205, 208, 210-212, 216, 221, 224,
228
open, 194

mutable, 195, 197, 198, 200, 203
new, 173, 189
nonrec, 195

object, 173, 190, 198, 200
of, 164, 195, 224
open, 171, 205, 208, 210, 212
open!, 229
or, 173, 174, 183

private, 198, 200, 203, 204, 218, 219

rec, see let, module

sig, 205, 206
struct, 210

then, see if
to, see for
true, 165
try, 173, 174, 184
type, 195, 205, 207, 208, 210-212, 220, 224,
230

val, 198, 200, 203, 205, 207, 221
virtual, see val, method, class

when, 173, 179, 231
while, 183
with, 173, 205, 209, 221, 224