summaryrefslogtreecommitdiff
path: root/manual/src/library/builtin.etex
blob: 4b1d805661158112963813e9cddae28489997dcd (plain)
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
\section{s:core-builtins}{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.

%\vspace{0.1cm}
\subsection*{ss:builtin-types}{Built-in types}
%\vspace{0.1cm}

\begin{ocamldoccode}
 type int
\end{ocamldoccode}
\index{int@\verb`int`}
\begin{ocamldocdescription}
    The type of integer numbers.
\end{ocamldocdescription}

\begin{ocamldoccode}
 type char
\end{ocamldoccode}
\index{char@\verb`char`}
\begin{ocamldocdescription}
   The type of characters.
\end{ocamldocdescription}

\begin{ocamldoccode}
 type bytes
\end{ocamldoccode}
\index{bytes@\verb`bytes`}
\begin{ocamldocdescription}
 The type of (writable) byte sequences.
\end{ocamldocdescription}

\begin{ocamldoccode}
 type string
\end{ocamldoccode}
\index{string@\verb`string`}
\begin{ocamldocdescription}
 The type of (read-only) character strings.
\end{ocamldocdescription}

\begin{ocamldoccode}
 type float
\end{ocamldoccode}
\index{float@\verb`float`}
\begin{ocamldocdescription}
  The type of floating-point numbers.
\end{ocamldocdescription}

\begin{ocamldoccode}
 type bool = false | true
\end{ocamldoccode}
\index{bool@\verb`bool`}
\begin{ocamldocdescription}
   The type of booleans (truth values).
\end{ocamldocdescription}

\begin{ocamldoccode}
 type unit = ()
\end{ocamldoccode}
\index{unit@\verb`unit`}
\begin{ocamldocdescription}
 The type of the unit value.
\end{ocamldocdescription}

\begin{ocamldoccode}
 type exn
\end{ocamldoccode}
\index{exn@\verb`exn`}
\begin{ocamldocdescription}
    The type of exception values.
\end{ocamldocdescription}

\begin{ocamldoccode}
 type 'a array
\end{ocamldoccode}
\index{array@\verb`array`}
\begin{ocamldocdescription}
  The type of arrays whose elements have type "'a".
\end{ocamldocdescription}

\begin{ocamldoccode}
 type 'a list = [] | :: of 'a * 'a list
\end{ocamldoccode}
\index{list@\verb`list`}
\begin{ocamldocdescription}
  The type of lists whose elements have type "'a".
\end{ocamldocdescription}

\begin{ocamldoccode}
type 'a option = None | Some of 'a
\end{ocamldoccode}
\index{option@\verb`option`}
\begin{ocamldocdescription}
  The type of optional values of type "'a".
\end{ocamldocdescription}

\begin{ocamldoccode}
type int32
\end{ocamldoccode}
\index{int32@\verb`int32`}
\begin{ocamldocdescription}
 The type of signed 32-bit integers.
 Literals for 32-bit integers are suffixed by l.
 See the \stdmoduleref{Int32} module.
\end{ocamldocdescription}

\begin{ocamldoccode}
type int64
\end{ocamldoccode}
\index{int64@\verb`int64`}
\begin{ocamldocdescription}
 The type of signed 64-bit integers.
 Literals for 64-bit integers are suffixed by L.
 See the \stdmoduleref{Int64} module.
\end{ocamldocdescription}

\begin{ocamldoccode}
type nativeint
\end{ocamldoccode}
\index{nativeint@\verb`nativeint`}
\begin{ocamldocdescription}
 The type of signed, platform-native integers (32 bits on 32-bit
 processors, 64 bits on 64-bit processors).
 Literals for native integers are suffixed by n.
 See the \stdmoduleref{Nativeint} module.
\end{ocamldocdescription}

\begin{ocamldoccode}
type ('a, 'b, 'c, 'd, 'e, 'f) format6
\end{ocamldoccode}
\index{format4@\verb`format4`}
\begin{ocamldocdescription}
  The type of format strings. "'a" is the type of the parameters of
  the format, "'f" is the result type for the "printf"-style
  functions, "'b" is the type of the first argument given to "%a" and
  "%t" printing functions (see module \stdmoduleref{Printf}),
  "'c" is the result type of these functions, and also the type of the
  argument transmitted to the first argument of "kprintf"-style
  functions, "'d" is the result type for the "scanf"-style functions
  (see module \stdmoduleref{Scanf}), and "'e" is the type of the receiver function
  for the "scanf"-style functions.
\end{ocamldocdescription}

\begin{ocamldoccode}
type 'a lazy_t
\end{ocamldoccode}
\index{lazyt@\verb`lazy_t`}
\begin{ocamldocdescription}
 This type is used to implement the \stdmoduleref{Lazy} module.
 It should not be used directly.
\end{ocamldocdescription}

%\vspace{0.1cm}
\subsection*{ss:predef-exn}{Predefined exceptions}
%\vspace{0.1cm}

\begin{ocamldoccode}
exception Match_failure of (string * int * int)
\end{ocamldoccode}
\index{Matchfailure@\verb`Match_failure`}
\begin{ocamldocdescription}
   Exception raised when none of the cases of a pattern-matching
   apply. The arguments are the location of the "match" keyword
   in the source code (file name, line number, column number).
\end{ocamldocdescription}

\begin{ocamldoccode}
exception Assert_failure of (string * int * int)
\end{ocamldoccode}
\index{Assertfailure@\verb`Assert_failure`}
\begin{ocamldocdescription}
   Exception raised when an assertion fails.  The arguments are
   the location of the "assert" keyword in the source code
   (file name, line number, column number).
\end{ocamldocdescription}

\begin{ocamldoccode}
exception Invalid_argument of string
\end{ocamldoccode}
\index{Invalidargument@\verb`Invalid_argument`}
\begin{ocamldocdescription}
   Exception raised by library functions to signal that the given
   arguments do not make sense.  The string gives some information
   to the programmer.  As a general rule, this exception should not
   be caught, it denotes a programming error and the code should be
   modified not to trigger it.
\end{ocamldocdescription}

\begin{ocamldoccode}
exception Failure of string
\end{ocamldoccode}
\index{Failure@\verb`Failure`}
\begin{ocamldocdescription}
  Exception raised by library functions to signal that they are
  undefined on the given arguments.  The string is meant to give some
  information to the programmer; you must \emph{not} pattern match on
  the string literal because it may change in future versions (use
  \verb`Failure _` instead).
\end{ocamldocdescription}

\begin{ocamldoccode}
exception Not_found
\end{ocamldoccode}
\index{Notfound@\verb`Not_found`}
\begin{ocamldocdescription}
   Exception raised by search functions when the desired object
   could not be found.
\end{ocamldocdescription}

\begin{ocamldoccode}
exception Out_of_memory
\end{ocamldoccode}
\index{Outofmemory@\verb`Out_of_memory`}
\begin{ocamldocdescription}
   Exception raised by the garbage collector when there is
   insufficient memory to complete the computation. (Not reliable for
   allocations on the minor heap.)
\end{ocamldocdescription}

\begin{ocamldoccode}
exception Stack_overflow
\end{ocamldoccode}
\index{Stackoverflow@\verb`Stack_overflow`}
\begin{ocamldocdescription}
   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. Before 4.10, it
   was not fully implemented by the native-code compiler.
\end{ocamldocdescription}

\begin{ocamldoccode}
exception Sys_error of string
\end{ocamldoccode}
\index{Syserror@\verb`Sys_error`}
\begin{ocamldocdescription}
  Exception raised by the input/output functions to report an
  operating system error.  The string is meant to give some
  information to the programmer; you must \emph{not} pattern match on
  the string literal because it may change in future versions (use
  \verb`Sys_error _` instead).
\end{ocamldocdescription}

\begin{ocamldoccode}
exception End_of_file
\end{ocamldoccode}
\index{Endoffile@\verb`End_of_file`}
\begin{ocamldocdescription}
   Exception raised by input functions to signal that the
   end of file has been reached.
\end{ocamldocdescription}

\begin{ocamldoccode}
exception Division_by_zero
\end{ocamldoccode}
\index{Divisionbyzero@\verb`Division_by_zero`}
\begin{ocamldocdescription}
   Exception raised by integer division and remainder operations
   when their second argument is zero.
\end{ocamldocdescription}

\begin{ocamldoccode}
exception Sys_blocked_io
\end{ocamldoccode}
\index{Sysblockedio@\verb`Sys_blocked_io`}
\begin{ocamldocdescription}
   A special case of "Sys_error" raised when no I/O is possible
   on a non-blocking I/O channel.
\end{ocamldocdescription}

\begin{ocamldoccode}
exception Undefined_recursive_module of (string * int * int)
\end{ocamldoccode}
\index{Undefinedrecursivemodule@\verb`Undefined_recursive_module`}
\begin{ocamldocdescription}
   Exception raised when an ill-founded recursive module definition
   is evaluated.  (See section~\ref{s:recursive-modules}.)
   The arguments are the location of the definition in the source code
   (file name, line number, column number).
\end{ocamldocdescription}