Node: Enumeration Clauses, Next: Address Clauses, Previous: Record Representation Clauses, Up: Representation Clauses and Pragmas
The only restriction on enumeration clauses is that the range of values must be representable. For the signed case, if one or more of the representation values are negative, all values must be in the range:
System.Min_Int .. System.Max_Int
For the unsigned case, where all values are non negative, the values must be in the range:
0 .. System.Max_Binary_Modulus;
A "confirming" representation clause is one in which the values range from 0 in sequence, i.e. a clause that confirms the default representation for an enumeration type. Such a confirming representation is permitted by these rules, and is specially recognized by the compiler so that no extra overhead results from the use of such a clause.
If an array has an index type which is an enumeration type to which an enumeration clause has been applied, then the array is stored in a compact manner. Consider the declarations:
type r is (A, B, C); for r use (A => 1, B => 5, C => 10); type t is array (r) of Character;
The array type t corresponds to a vector with exactly three elements and
has a default size equal to 3*Character'Size
. This ensures efficient
use of space, but means that accesses to elements of the array will incur
the overhead of converting representation values to the corresponding
positional values, (i.e. the value delivered by the Pos
attribute).