summaryrefslogtreecommitdiff
path: root/manual/src/refman/values.etex
blob: d7e0b696dc0d89bf5f5803e7e1599d5a38137432 (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
\section{s:values}{Values}
%HEVEA\cutname{values.html}

This section describes the kinds of values that are manipulated by
OCaml programs.

\subsection{ss:values:base}{Base values}

\subsubsection*{sss:values:integer}{Integer numbers}

Integer values are integer numbers from $-2^{30}$ to $2^{30}-1$, that
is $-1073741824$ to $1073741823$. The implementation may support a
wider range of integer values: on 64-bit platforms, the current
implementation supports integers ranging from $-2^{62}$ to $2^{62}-1$.

\subsubsection*{sss:values:float}{Floating-point numbers}

Floating-point values are numbers in floating-point representation.
The current implementation uses double-precision floating-point
numbers conforming to the IEEE 754 standard, with 53 bits of mantissa
and an exponent ranging from $-1022$ to $1023$.

\subsubsection*{sss:values:char}{Characters}

Character values are represented as 8-bit integers between 0 and 255.
Character codes between 0 and 127 are interpreted following the ASCII
standard. The current implementation interprets character codes
between 128 and 255 following the ISO 8859-1 standard.

\subsubsection*{sss:values:string}{Character strings}

String values are finite sequences of characters. The current
implementation supports strings containing up to $2^{24} - 5$
characters (16777211 characters); on 64-bit platforms, the limit is
$2^{57} - 9$.

\subsection{ss:values:tuple}{Tuples}

Tuples of values are written @'('@v@_1',' \ldots',' @v@_n')'@, standing for the
$n$-tuple of values @@v@_1@ to @@v@_n@. The current implementation
supports tuple of up to $2^{22} - 1$ elements (4194303 elements).

\subsection{ss:values:records}{Records}

Record values are labeled tuples of values. The record value written
@'{' field_1 '=' @v@_1';' \ldots';' field_n '=' @v@_n '}'@ associates the value
@@v@_i@ to the record field @field_i@, for $i = 1 \ldots n$. The current
implementation supports records with up to $2^{22} - 1$ fields
(4194303 fields).

\subsection{ss:values:array}{Arrays}

Arrays are finite, variable-sized sequences of values of the same
type.  The current implementation supports arrays containing up to
$2^{22} - 1$ elements (4194303 elements) unless the elements are
floating-point numbers (2097151 elements in this case); on 64-bit
platforms, the limit is $2^{54} - 1$ for all arrays.

\subsection{ss:values:variant}{Variant values}

Variant values are either a constant constructor, or a non-constant
constructor applied to a number of values. The former case is written
@constr@; the latter case is written @constr '('@v@_1',' ... ',' @v@_n
')'@, where the @@v@_i@ are said to be the arguments of the non-constant
constructor @constr@. The parentheses may be omitted if there is only
one argument.

The following constants are treated like built-in constant
constructors:
\begin{tableau}{|l|l|}{Constant}{Constructor}
\entree{"false"}{the boolean false}
\entree{"true"}{the boolean true}
\entree{"()"}{the ``unit'' value}
\entree{"[]"}{the empty list}
\end{tableau}

The current implementation limits each variant type to have at most
246 non-constant constructors and $2^{30}-1$ constant constructors.

\subsection{ss:values:polyvars}{Polymorphic variants}

Polymorphic variants are an alternate form of variant values, not
belonging explicitly to a predefined variant type, and following
specific typing rules. They can be either constant, written
@"`"tag-name@, or non-constant, written @"`"tag-name'('@v@')'@.

\subsection{ss:values:fun}{Functions}

Functional values are mappings from values to values.

\subsection{ss:values:obj}{Objects}

Objects are composed of a hidden internal state which is a
record of instance variables, and a set of methods for accessing and
modifying these variables.  The structure of an object is described by
the toplevel class that created it.