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
|
<!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>
Values
</TITLE>
</HEAD>
<BODY >
<A HREF="manual009.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="manual011.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>
<H2 CLASS="section"><A NAME="htoc53">6.2</A> Values</H2>
This section describes the kinds of values that are manipulated by
Objective Caml programs.<BR>
<BR>
<H3 CLASS="subsection"><A NAME="htoc54">6.2.1</A> Base values</H3>
<H4 CLASS="subsubsection">Integer numbers</H4>
Integer values are integer numbers from −2<SUP>30</SUP> to 2<SUP>30</SUP>−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<SUP>62</SUP> to 2<SUP>62</SUP>−1.<BR>
<BR>
<H4 CLASS="subsubsection">Floating-point numbers</H4>
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.<BR>
<BR>
<H4 CLASS="subsubsection">Characters</H4>
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.<BR>
<BR>
<H4 CLASS="subsubsection">Character strings</H4> <A NAME="s:string-val"></A>
String values are finite sequences of characters. The current
implementation supports strings containing up to 2<SUP>24</SUP> − 5
characters (16777211 characters); on 64-bit platforms, the limit is
2<SUP>57</SUP> − 9.<BR>
<BR>
<H3 CLASS="subsection"><A NAME="htoc55">6.2.2</A> Tuples</H3>
Tuples of values are written (<I>v</I><SUB>1</SUB>, …, <I>v<SUB>n</SUB></I>), standing for the
<I>n</I>-tuple of values <I>v</I><SUB>1</SUB> to <I>v<SUB>n</SUB></I>. The current implementation
supports tuple of up to 2<SUP>22</SUP> − 1 elements (4194303 elements).<BR>
<BR>
<H3 CLASS="subsection"><A NAME="htoc56">6.2.3</A> Records</H3>
Record values are labeled tuples of values. The record value written
{ <I>field</I><SUB>1</SUB> = <I>v</I><SUB>1</SUB>; …; <I>field<SUB>n</SUB></I> = <I>v<SUB>n</SUB></I> } associates the value
<I>v<SUB>i</SUB></I> to the record field <I>field<SUB>i</SUB></I>, for <I>i</I> = 1 … <I>n</I>. The current
implementation supports records with up to 2<SUP>22</SUP> − 1 fields
(4194303 fields).<BR>
<BR>
<H3 CLASS="subsection"><A NAME="htoc57">6.2.4</A> Arrays</H3>
Arrays are finite, variable-sized sequences of values of the same
type. The current implementation supports arrays containing up to
2<SUP>22</SUP> − 1 elements (4194303 elements)
<div style="background-color:yellow; color:red; border-style:none; border-width:0.5pt">
unless the elements are
floating-point numbers (2097151 elements in this case);
</div>
on 64-bit
platforms, the limit is 2<SUP>54</SUP> − 1 for all arrays.<BR>
<BR>
<H3 CLASS="subsection"><A NAME="htoc58">6.2.5</A> Variant values</H3>
Variant values are either a constant constructor, or a pair of a
non-constant constructor and a value. The former case is written
<I>constr</I>; the latter case is written <I>constr</I>(<I>v</I>), where <I>v</I> is said
to be the argument of the non-constant constructor <I>constr</I>.<BR>
<BR>
The following constants are treated like built-in constant
constructors:
<BR>
<BR>
<DIV CLASS="center"><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%">
<TR><TD ALIGN=center NOWRAP><B>Constant</B></TD>
<TD ALIGN=center NOWRAP><B>Constructor</B></TD>
</TR>
<TR><TD ALIGN=left NOWRAP>
<TT>false</TT></TD>
<TD ALIGN=left NOWRAP>the boolean false</TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT>true</TT></TD>
<TD ALIGN=left NOWRAP>the boolean true</TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT>()</TT></TD>
<TD ALIGN=left NOWRAP>the “unit” value</TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT>[]</TT></TD>
<TD ALIGN=left NOWRAP>the empty list</TD>
</TR></TABLE></DIV><BR>
<BR>
The current implementation limits each variant type to have at most
246 non-constant constructors.<BR>
<BR>
<H3 CLASS="subsection"><A NAME="htoc59">6.2.6</A> Polymorphic variants</H3>
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
<TT><FONT COLOR=blue>`</FONT><FONT COLOR=maroon><I>tag-name</I></FONT></TT>, or non-constant, written <TT><FONT COLOR=blue>`</FONT><FONT COLOR=maroon><I>tag-name</I></FONT></TT> (<FONT COLOR=maroon><I><TT>v</TT></I></FONT>).<BR>
<BR>
<H3 CLASS="subsection"><A NAME="htoc60">6.2.7</A> Functions</H3>
Functional values are mappings from values to values.<BR>
<BR>
<H3 CLASS="subsection"><A NAME="htoc61">6.2.8</A> Objects</H3>
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.<BR>
<BR>
<BR>
<BR>
<HR>
<A HREF="manual009.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="manual011.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
|