Preloaded Library

The Pervasives library is always preloaded so that it will be available
at the toplevel (interactive) loop or for inline compilation. It is always linked
and is the initial environment of the language. It contains the
declarations of:

exceptions: A number of exceptions are raisable by the execution
library. Some of the more common ones are the following:

Failureofstring that is raised by the function
failwith applied to a string.

Invalid_argumentofstring that indicates that an argument
cannot be handled by the function having raised the exception.
The function invalid_arg
applied to a string starts this exception.

Sys_errorofstring, for the input/output, typically
in attempting to open a nonexistent file for reading.

End_of_file for detecting the end of a file.

Division_by_zero for zero divide errors between integers.

As well as internal exceptions like:

Out_of_memory and Stack_overflow for going
beyond the memory of the heap or the stack. It should be noted that
a program cannot recover from the Out_of_memory exception.
In effect, when it is raised it is too late to allocate new memory space
to continue functioning.Handling the Stack_Overflow exception
differs depending on whether the program was compiled in byte code or native
code. In the latter case, it is not possible to recover.

functions: there are roughly 140, half of which correspond to the C
functions of the execution library. There you may find mathematical and
comparison operators, functions on integer and floating-point numbers,
functions on character strings, on references and input-output. It should
be noted that a certain number of these declarations are in fact synonyms
for declarations defined in other modules. They are nevertheless declared
here for historical and implementation reasons.