Sophie

Sophie

distrib > Mageia > 6 > x86_64 > media > core-updates > by-pkgid > aad5e8d45f28c2d43a4dc470983b342c > files > 280

ocaml-doc-4.02.3-6.1.mga6.noarch.rpm

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="generator" content="hevea 2.00">
<link rel="stylesheet" type="text/css" href="manual.css">
<title>Values</title>
</head>
<body>
<a href="lex.html"><img src="previous_motif.gif" alt="Previous"></a>
<a href="language.html"><img src="contents_motif.gif" alt="Up"></a>
<a href="names.html"><img src="next_motif.gif" alt="Next"></a>
<hr>
<h2 class="section" id="sec75">6.2&#XA0;&#XA0;Values</h2>
<ul>
<li><a href="values.html#sec76">Base values</a>
</li><li><a href="values.html#sec81">Tuples</a>
</li><li><a href="values.html#sec82">Records</a>
</li><li><a href="values.html#sec83">Arrays</a>
</li><li><a href="values.html#sec84">Variant values</a>
</li><li><a href="values.html#sec85">Polymorphic variants</a>
</li><li><a href="values.html#sec86">Functions</a>
</li><li><a href="values.html#sec87">Objects</a>
</li></ul>
<p>This section describes the kinds of values that are manipulated by
OCaml programs.</p>
<h3 class="subsection" id="sec76">6.2.1&#XA0;&#XA0;Base values</h3>
<h4 class="subsubsection" id="sec77">Integer numbers</h4>
<p>Integer values are integer numbers from &#X2212;2<sup>30</sup> to 2<sup>30</sup>&#X2212;1, that
is &#X2212;1073741824 to 1073741823. The implementation may support a
wider range of integer values: on 64-bit platforms, the current
implementation supports integers ranging from &#X2212;2<sup>62</sup> to 2<sup>62</sup>&#X2212;1.</p><h4 class="subsubsection" id="sec78">Floating-point numbers</h4>
<p>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 &#X2212;1022 to 1023.</p><h4 class="subsubsection" id="sec79">Characters</h4>
<p>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.</p><h4 class="subsubsection" id="sec80">Character strings</h4>
<p>String values are finite sequences of characters. The current
implementation supports strings containing up to 2<sup>24</sup> &#X2212; 5
characters (16777211 characters); on 64-bit platforms, the limit is
2<sup>57</sup> &#X2212; 9.</p>
<h3 class="subsection" id="sec81">6.2.2&#XA0;&#XA0;Tuples</h3>
<p>Tuples of values are written <span class="c008">(</span><span class="c014">v</span><sub>1</sub><span class="c008">,</span> &#X2026;<span class="c008">,</span> <span class="c014">v</span><sub><span class="c013">n</span></sub><span class="c008">)</span>, standing for the
<span class="c013">n</span>-tuple of values <span class="c014">v</span><sub>1</sub> to <span class="c014">v</span><sub><span class="c013">n</span></sub>. The current implementation
supports tuple of up to 2<sup>22</sup> &#X2212; 1 elements (4194303 elements).</p>
<h3 class="subsection" id="sec82">6.2.3&#XA0;&#XA0;Records</h3>
<p>Record values are labeled tuples of values. The record value written
<span class="c008">{</span> <a class="syntax" href="names.html#field"><span class="c014">field</span></a><sub>1</sub> <span class="c008">=</span> <span class="c014">v</span><sub>1</sub><span class="c008">;</span> &#X2026;<span class="c008">;</span> &#XA0;<a class="syntax" href="names.html#field"><span class="c014">field</span></a><sub><span class="c013">n</span></sub> <span class="c008">=</span> <span class="c014">v</span><sub><span class="c013">n</span></sub> <span class="c008">}</span> associates the value
<span class="c014">v</span><sub><span class="c013">i</span></sub> to the record field <a class="syntax" href="names.html#field"><span class="c014">field</span></a><sub><span class="c013">i</span></sub>, for <span class="c013">i</span> = 1 &#X2026; <span class="c013">n</span>. The current
implementation supports records with up to 2<sup>22</sup> &#X2212; 1 fields
(4194303 fields).</p>
<h3 class="subsection" id="sec83">6.2.4&#XA0;&#XA0;Arrays</h3>
<p>Arrays are finite, variable-sized sequences of values of the same
type. The current implementation supports arrays containing up to
2<sup>22</sup> &#X2212; 1 elements (4194303 elements) unless the elements are
floating-point numbers (2097151 elements in this case); on 64-bit
platforms, the limit is 2<sup>54</sup> &#X2212; 1 for all arrays.</p>
<h3 class="subsection" id="sec84">6.2.5&#XA0;&#XA0;Variant values</h3>
<p>Variant values are either a constant constructor, or a non-constant
constructor applied to a number of values. The former case is written
<a class="syntax" href="names.html#constr"><span class="c014">constr</span></a>; the latter case is written <a class="syntax" href="names.html#constr"><span class="c014">constr</span></a> <span class="c008">(</span><span class="c014">v</span><sub>1</sub><span class="c008">,</span> ... <span class="c008">,</span> <span class="c014">v</span><sub><span class="c013">n</span></sub>
<span class="c008">)</span>, where the <span class="c014">v</span><sub><span class="c013">i</span></sub> are said to be the arguments of the non-constant
constructor <a class="syntax" href="names.html#constr"><span class="c014">constr</span></a>. The parentheses may be omitted if there is only
one argument.</p><p>The following constants are treated like built-in constant
constructors:
</p><div class="center"><table class="c001 cellpadding1" border=1><tr><td class="c021"><span class="c019">Constant</span></td><td class="c021"><span class="c019">Constructor</span> </td></tr>
<tr><td class="c023">
<span class="c007">false</span></td><td class="c023">the boolean false </td></tr>
<tr><td class="c023"><span class="c007">true</span></td><td class="c023">the boolean true </td></tr>
<tr><td class="c023"><span class="c007">()</span></td><td class="c023">the &#X201C;unit&#X201D; value </td></tr>
<tr><td class="c023"><span class="c007">[]</span></td><td class="c023">the empty list </td></tr>
</table></div><p>The current implementation limits each variant type to have at most
246 non-constant constructors and 2<sup>30</sup>&#X2212;1 constant constructors.</p>
<h3 class="subsection" id="sec85">6.2.6&#XA0;&#XA0;Polymorphic variants</h3>
<p>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
<span class="c008">`</span><a class="syntax" href="names.html#tag-name"><span class="c014">tag-name</span></a>, or non-constant, written <span class="c008">`</span><a class="syntax" href="names.html#tag-name"><span class="c014">tag-name</span></a><span class="c005"><span class="c007">(</span><span class="c014">v</span><span class="c007">)</span></span>.</p>
<h3 class="subsection" id="sec86">6.2.7&#XA0;&#XA0;Functions</h3>
<p>Functional values are mappings from values to values.</p>
<h3 class="subsection" id="sec87">6.2.8&#XA0;&#XA0;Objects</h3>
<p>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.

</p>
<hr>
<a href="lex.html"><img src="previous_motif.gif" alt="Previous"></a>
<a href="language.html"><img src="contents_motif.gif" alt="Up"></a>
<a href="names.html"><img src="next_motif.gif" alt="Next"></a>
</body>
</html>