Previous Contents Next
Chapter 19 The core library

This chapter describes the Objective Caml core library, which is composed of declarations for built-in types and exceptions, plus the module Pervasives that provides basic operations on these built-in types. The Pervasives module is special in two ways:
Conventions

The declarations of the built-in types and the components of module Pervasives are printed one by one in typewriter font, followed by a short comment. All library modules and the components they provide are indexed at the end of this report.

19.1 Built-in types and predefined exceptions

The following built-in types and predefined exceptions are always defined in the compilation environment, but are not part of any module. As a consequence, they can only be referred by their short names.

Built-in types
 type int
The type of integer numbers.
 type char
The type of characters.
 type string
The type of character strings.
 type float
The type of floating-point numbers.
 type bool = false | true
The type of booleans (truth values).
 type unit = ()
The type of the unit value.
 type exn
The type of exception values.
 type 'a array
The type of arrays whose elements have type 'a.
 type 'a list = [] | :: of 'a * 'a list
The type of lists whose elements have type 'a.
type 'a option = None | Some of 'a
The type of optional values of type 'a.
type ('a, 'b, 'c) format
The type of format strings. 'a is the type of the parameters of the format, 'c is the result type for the printf-style function, and 'b is the type of the first argument given to \%a and \%t printing functions (see module Printf[??]).
type 'a lazy_t
This type is used to implement the Lazy[??] module. It should not be used directly.
Predefined exceptions
exception Match_failure of (string * int * int)
Exception raised when none of the cases of a pattern-matching apply. The arguments are the location of the pattern-matching in the source code (file name, position of first character, position of last character).
exception Assert_failure of (string * int * int)
Exception raised when an assertion fails. The arguments are the location of the pattern-matching in the source code (file name, position of first character, position of last character).
exception Invalid_argument of string
Exception raised by library functions to signal that the given arguments do not make sense.
exception Failure of string
Exception raised by library functions to signal that they are undefined on the given arguments.
exception Not_found
Exception raised by search functions when the desired object could not be found.
exception Out_of_memory
Exception raised by the garbage collector when there is insufficient memory to complete the computation.
exception Stack_overflow
Exception raised by the bytecode interpreter when the evaluation stack reaches its maximal size. This often indicates infinite or excessively deep recursion in the user's program. (Not fully implemented by the native-code compiler; see section 11.4.)
exception Sys_error of string
Exception raised by the input/output functions to report an operating system error.
exception End_of_file
Exception raised by input functions to signal that the end of file has been reached.
exception Division_by_zero
Exception raised by division and remainder operations when their second argument is null. (Not fully implemented by the native-code compiler; see section 11.4.)
exception Sys_blocked_io
A special case of Sys_error raised when no I/O is possible on a non-blocking I/O channel.
Module Pervasives: the initially opened module




Previous Contents Next