File: manual033.html

package info (click to toggle)
ocaml-doc 3.10-1
  • links: PTS, VCS
  • area: non-free
  • in suites: lenny
  • size: 7,476 kB
  • ctags: 2,644
  • sloc: ml: 325; sh: 64; makefile: 34; ansic: 15
file content (233 lines) | stat: -rw-r--r-- 8,704 bytes parent folder | download
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
<!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.09">
<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">Chapter19</A>The core library</H1><P> <A NAME="c:corelib"></A>
</P><P>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:
</P><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>).</LI><LI CLASS="li-itemize">It is automatically &#X201C;opened&#X201D; 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.
</LI></UL><H2 CLASS="section">Conventions</H2><P>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.</P><H2 CLASS="section"><A NAME="htoc250">19.1</A>Built-in types and predefined exceptions</H2><P>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.</P><H3 CLASS="subsection">Built-in types</H3><PRE>
 type int
</PRE><P>
<A NAME="@manual9"></A>
</P><BLOCKQUOTE CLASS="quote">
The type of integer numbers.
</BLOCKQUOTE><PRE>
 type char
</PRE><P>
<A NAME="@manual10"></A>
</P><BLOCKQUOTE CLASS="quote">
The type of characters.
</BLOCKQUOTE><PRE>
 type string
</PRE><P>
<A NAME="@manual11"></A>
</P><BLOCKQUOTE CLASS="quote">
The type of character strings.
</BLOCKQUOTE><PRE>
 type float
</PRE><P>
<A NAME="@manual12"></A>
</P><BLOCKQUOTE CLASS="quote">
The type of floating-point numbers.
</BLOCKQUOTE><PRE>
 type bool = false | true
</PRE><P>
<A NAME="@manual13"></A>
</P><BLOCKQUOTE CLASS="quote">
The type of booleans (truth values).
</BLOCKQUOTE><PRE>
 type unit = ()
</PRE><P>
<A NAME="@manual14"></A>
</P><BLOCKQUOTE CLASS="quote">
The type of the unit value.
</BLOCKQUOTE><PRE>
 type exn
</PRE><P>
<A NAME="@manual15"></A>
</P><BLOCKQUOTE CLASS="quote">
The type of exception values.
</BLOCKQUOTE><PRE>
 type 'a array
</PRE><P>
<A NAME="@manual16"></A>
</P><BLOCKQUOTE CLASS="quote">
The type of arrays whose elements have type <TT>'a</TT>.
</BLOCKQUOTE><PRE>
 type 'a list = [] | :: of 'a * 'a list
</PRE><P>
<A NAME="@manual17"></A>
</P><BLOCKQUOTE CLASS="quote">
The type of lists whose elements have type <TT>'a</TT>.
</BLOCKQUOTE><PRE>
type 'a option = None | Some of 'a
</PRE><P>
<A NAME="@manual18"></A>
</P><BLOCKQUOTE CLASS="quote">
The type of optional values of type <TT>'a</TT>. 
</BLOCKQUOTE><PRE>
type int32
</PRE><P>
<A NAME="@manual19"></A>
</P><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><P>
<A NAME="@manual20"></A>
</P><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><P>
<A NAME="@manual21"></A>
</P><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><P>
<A NAME="@manual22"></A>
</P><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><P>
<A NAME="@manual23"></A>
</P><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><P>
<A NAME="@manual24"></A>
</P><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><P>
<A NAME="@manual25"></A>
</P><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><P>
<A NAME="@manual26"></A>
</P><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><P>
<A NAME="@manual27"></A>
</P><BLOCKQUOTE CLASS="quote">
Exception raised by library functions to signal that they are
undefined on the given arguments. 
</BLOCKQUOTE><PRE>
exception Not_found
</PRE><P>
<A NAME="@manual28"></A>
</P><BLOCKQUOTE CLASS="quote">
Exception raised by search functions when the desired object
could not be found.
</BLOCKQUOTE><PRE>
exception Out_of_memory
</PRE><P>
<A NAME="@manual29"></A>
</P><BLOCKQUOTE CLASS="quote">
Exception raised by the garbage collector
when there is insufficient memory to complete the computation.
</BLOCKQUOTE><PRE>
exception Stack_overflow
</PRE><P>
<A NAME="@manual30"></A>
</P><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><P>
<A NAME="@manual31"></A>
</P><BLOCKQUOTE CLASS="quote">
Exception raised by the input/output functions to report
an operating system error.
</BLOCKQUOTE><PRE>
exception End_of_file
</PRE><P>
<A NAME="@manual32"></A>
</P><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><P>
<A NAME="@manual33"></A>
</P><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><P>
<A NAME="@manual34"></A>
</P><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><P>
<A NAME="@manual35"></A>
</P><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><UL CLASS="ftoc2"><LI CLASS="li-links">
<A HREF="libref/Pervasives.html">Module <TT>Pervasives</TT>: the initially opened module</A>
</LI></UL><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>