1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="manual.css">
<TITLE>
The core library
</TITLE>
</HEAD>
<BODY >
<A HREF="manual032.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="manual034.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>
<H1 CLASS="chapter"><A NAME="htoc249">Chapter 19</A> The core library</H1> <A NAME="c:corelib"></A>
This chapter describes the Objective Caml core library, which is
composed of declarations for built-in types and exceptions, plus
the module <TT>Pervasives</TT> that provides basic operations on these
built-in types. The <TT>Pervasives</TT> module is special in two
ways:
<UL CLASS="itemize"><LI CLASS="li-itemize">
It is automatically linked with the user's object code files by
the <TT>ocamlc</TT> command (chapter <A HREF="manual022.html#c:camlc">8</A>).<BR>
<BR>
<LI CLASS="li-itemize">It is automatically “opened” when a compilation starts, or
when the toplevel system is launched. Hence, it is possible to use
unqualified identifiers to refer to the functions provided by the
<TT>Pervasives</TT> module, without adding a <TT>open Pervasives</TT> directive.
</UL>
<H2 CLASS="section">Conventions</H2>
The declarations of the built-in types and the components of module
<TT>Pervasives</TT> 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.<BR>
<BR>
<H2 CLASS="section"><A NAME="htoc250">19.1</A> Built-in types and predefined exceptions</H2>
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.<BR>
<BR>
<H3 CLASS="subsection">Built-in types</H3>
<PRE>
type int
</PRE>
<A NAME="@manual9"></A>
<BLOCKQUOTE CLASS="quote">
The type of integer numbers.
</BLOCKQUOTE>
<PRE>
type char
</PRE>
<A NAME="@manual10"></A>
<BLOCKQUOTE CLASS="quote">
The type of characters.
</BLOCKQUOTE>
<PRE>
type string
</PRE>
<A NAME="@manual11"></A>
<BLOCKQUOTE CLASS="quote">
The type of character strings.
</BLOCKQUOTE>
<PRE>
type float
</PRE>
<A NAME="@manual12"></A>
<BLOCKQUOTE CLASS="quote">
The type of floating-point numbers.
</BLOCKQUOTE>
<PRE>
type bool = false | true
</PRE>
<A NAME="@manual13"></A>
<BLOCKQUOTE CLASS="quote">
The type of booleans (truth values).
</BLOCKQUOTE>
<PRE>
type unit = ()
</PRE>
<A NAME="@manual14"></A>
<BLOCKQUOTE CLASS="quote">
The type of the unit value.
</BLOCKQUOTE>
<PRE>
type exn
</PRE>
<A NAME="@manual15"></A>
<BLOCKQUOTE CLASS="quote">
The type of exception values.
</BLOCKQUOTE>
<PRE>
type 'a array
</PRE>
<A NAME="@manual16"></A>
<BLOCKQUOTE CLASS="quote">
The type of arrays whose elements have type <TT>'a</TT>.
</BLOCKQUOTE>
<PRE>
type 'a list = [] | :: of 'a * 'a list
</PRE>
<A NAME="@manual17"></A>
<BLOCKQUOTE CLASS="quote">
The type of lists whose elements have type <TT>'a</TT>.
</BLOCKQUOTE>
<PRE>
type 'a option = None | Some of 'a
</PRE>
<A NAME="@manual18"></A>
<BLOCKQUOTE CLASS="quote">
The type of optional values of type <TT>'a</TT>.
</BLOCKQUOTE>
<PRE>
type int32
</PRE>
<A NAME="@manual19"></A>
<BLOCKQUOTE CLASS="quote">
The type of signed 32-bit integers.
See the <TT>Int32</TT>[<TT><A HREF="libref/Int32.html">Int32</A></TT>] module.
</BLOCKQUOTE>
<PRE>
type int64
</PRE>
<A NAME="@manual20"></A>
<BLOCKQUOTE CLASS="quote">
The type of signed 64-bit integers.
See the <TT>Int64</TT>[<TT><A HREF="libref/Int64.html">Int64</A></TT>] module.
</BLOCKQUOTE>
<PRE>
type nativeint
</PRE>
<A NAME="@manual21"></A>
<BLOCKQUOTE CLASS="quote">
The type of signed, platform-native integers (32 bits on 32-bit
processors, 64 bits on 64-bit processors).
See the <TT>Nativeint</TT>[<TT><A HREF="libref/Nativeint.html">Nativeint</A></TT>] module.
</BLOCKQUOTE>
<PRE>
type ('a, 'b, 'c, 'd) format4
</PRE>
<A NAME="@manual22"></A>
<BLOCKQUOTE CLASS="quote">
The type of format strings. <TT>'a</TT> is the type of the parameters
of the format, <TT>'d</TT> is the result type for the <TT>printf</TT>-style
function, <TT>'b</TT> is the type of the first argument given to
<TT>\%a</TT> and <TT>\%t</TT> printing functions (see module <TT>Printf</TT>[<TT><A HREF="libref/Printf.html">Printf</A></TT>]),
and <TT>'c</TT> is the result type of these functions.
</BLOCKQUOTE>
<PRE>
type 'a lazy_t
</PRE>
<A NAME="@manual23"></A>
<BLOCKQUOTE CLASS="quote">
This type is used to implement the <TT>Lazy</TT>[<TT><A HREF="libref/Lazy.html">Lazy</A></TT>] module.
It should not be used directly.
</BLOCKQUOTE>
<H3 CLASS="subsection">Predefined exceptions</H3>
<PRE>
exception Match_failure of (string * int * int)
</PRE>
<A NAME="@manual24"></A>
<BLOCKQUOTE CLASS="quote">
Exception raised when none of the cases of a pattern-matching
apply. The arguments are the location of the <TT>match</TT> keyword
in the source code (file name, line number, column number).
</BLOCKQUOTE>
<PRE>
exception Assert_failure of (string * int * int)
</PRE>
<A NAME="@manual25"></A>
<BLOCKQUOTE CLASS="quote">
Exception raised when an assertion fails. The arguments are
the location of the <TT>assert</TT> keyword in the source code
(file name, line number, column number).
</BLOCKQUOTE>
<PRE>
exception Invalid_argument of string
</PRE>
<A NAME="@manual26"></A>
<BLOCKQUOTE CLASS="quote">
Exception raised by library functions to signal that the given
arguments do not make sense.
</BLOCKQUOTE>
<PRE>
exception Failure of string
</PRE>
<A NAME="@manual27"></A>
<BLOCKQUOTE CLASS="quote">
Exception raised by library functions to signal that they are
undefined on the given arguments.
</BLOCKQUOTE>
<PRE>
exception Not_found
</PRE>
<A NAME="@manual28"></A>
<BLOCKQUOTE CLASS="quote">
Exception raised by search functions when the desired object
could not be found.
</BLOCKQUOTE>
<PRE>
exception Out_of_memory
</PRE>
<A NAME="@manual29"></A>
<BLOCKQUOTE CLASS="quote">
Exception raised by the garbage collector
when there is insufficient memory to complete the computation.
</BLOCKQUOTE>
<PRE>
exception Stack_overflow
</PRE>
<A NAME="@manual30"></A>
<BLOCKQUOTE CLASS="quote">
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 <A HREF="manual025.html#s:compat-native-bytecode">11.5</A>.)
</BLOCKQUOTE>
<PRE>
exception Sys_error of string
</PRE>
<A NAME="@manual31"></A>
<BLOCKQUOTE CLASS="quote">
Exception raised by the input/output functions to report
an operating system error.
</BLOCKQUOTE>
<PRE>
exception End_of_file
</PRE>
<A NAME="@manual32"></A>
<BLOCKQUOTE CLASS="quote">
Exception raised by input functions to signal that the
end of file has been reached.
</BLOCKQUOTE>
<PRE>
exception Division_by_zero
</PRE>
<A NAME="@manual33"></A>
<BLOCKQUOTE CLASS="quote">
Exception raised by division and remainder operations
when their second argument is null.
(Not fully implemented by the native-code compiler;
see section <A HREF="manual025.html#s:compat-native-bytecode">11.5</A>.)
</BLOCKQUOTE>
<PRE>
exception Sys_blocked_io
</PRE>
<A NAME="@manual34"></A>
<BLOCKQUOTE CLASS="quote">
A special case of <TT>Sys_error</TT> raised when no I/O is possible
on a non-blocking I/O channel.
</BLOCKQUOTE>
<PRE>
exception Undefined_recursive_module of (string * int * int)
</PRE>
<A NAME="@manual35"></A>
<BLOCKQUOTE CLASS="quote">
Exception raised when an ill-founded recursive module definition
is evaluated. (See section <A HREF="manual021.html#s-recursive-modules">7.9</A>.)
The arguments are the location of the definition in the source code
(file name, line number, column number).
</BLOCKQUOTE>
<H2 CLASS="section"><A NAME="htoc251">19.2</A> Module <TT>Pervasives</TT>: the initially opened module</H2>
<br>
<a HREF="libref/Pervasives.html"> Module <tt>Pervasives</tt>: the initially opened module</a> <img alt="updated" src="updated_tiny.gif">
<BR>
<BR>
<BR>
<BR>
<HR>
<A HREF="manual032.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="manual034.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
|