7.2 Values

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

7.2.1 Base values

Integer numbers

Integer values are integer numbers from −230 to 230−1, thatis −1073741824 to 1073741823. The implementation may support awider range of integer values: on 64-bit platforms, the currentimplementation supports integers ranging from −262 to 262−1.

Floating-point numbers

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

Characters

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

Character strings

String values are finite sequences of characters. The currentimplementation supports strings containing up to 224 − 5characters (16777211 characters); on 64-bit platforms, the limit is257 − 9.

7.2.2 Tuples

Tuples of values are written (v1, …,vn), standing for then-tuple of values v1 to vn. The current implementationsupports tuple of up to 222 − 1 elements (4194303 elements).

7.2.3 Records

Record values are labeled tuples of values. The record value written{field1=v1; …; fieldn=vn} associates the valuevi to the record field fieldi, for i = 1 … n. The currentimplementation supports records with up to 222 − 1 fields(4194303 fields).

7.2.4 Arrays

Arrays are finite, variable-sized sequences of values of the sametype. The current implementation supports arrays containing up to222 − 1 elements (4194303 elements) unless the elements arefloating-point numbers (2097151 elements in this case); on 64-bitplatforms, the limit is 254 − 1 for all arrays.

7.2.5 Variant values

Variant values are either a constant constructor, or a non-constantconstructor applied to a number of values. The former case is writtenconstr; the latter case is written constr(v1, … ,vn), where the vi are said to be the arguments of the non-constantconstructor constr. The parentheses may be omitted if there is onlyone argument.

The following constants are treated like built-in constantconstructors:

ConstantConstructor
falsethe boolean false
truethe boolean true
()the “unit” value
[]the empty list

The current implementation limits each variant type to have at most246 non-constant constructors and 230−1 constant constructors.

7.2.6 Polymorphic variants

Polymorphic variants are an alternate form of variant values, notbelonging explicitly to a predefined variant type, and followingspecific typing rules. They can be either constant, written[tag-name]($49815e5ab82eadea.md#tag-name), or non-constant, writtentag-name(v).

7.2.7 Functions

Functional values are mappings from values to values.

7.2.8 Objects

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