An enumeration representation clause specifies the internal codes for the literals of the enumeration type that is named in the clause.
enumeration_representation_clause ::= for type_simple_name use aggregate;
The aggregate used to specify this mapping is written as a one-dimensional aggregate, for which the index subtype is the enumeration type and the component type is universal_integer.
All literals of the enumeration type must be provided with distinct integer codes, and all choices and component values given in the aggregate must be static. The integer codes specified for the enumeration type must satisfy the predefined ordering relation of the type.
type MIX_CODE is (ADD, SUB, MUL, LDA, STA, STZ); for MIX_CODE use (ADD => 1, SUB =.2, MUL => 3, LDA => 8, STA => 24, STZ =>33);
The attributes SUCC, PRED, and POS are defined even for enumeration types with a noncontiguous representation; their definition corresponds to the (logical) type declaration and is not affected by the enumeration representation clause. In the example, because of the need to avoid the omitted values, these functions are likely to be less efficiently implemented than they could be in the absence of a representation clause. Similar considerations apply when such types are used for indexing.
References: aggregate, array aggregate, array type, attribute of an enumeration type, choice, component, enumeration literal, enumeration type, function, index, index subtype, literal, ordering relation of an enumeration type, representation clause, simple name, static expression, type, type declaration, universal_integer type.
Rationale references: 15.4.5 Enumeration Representation Clauses
Style Guide references: 3.4.2 Enumeration Types, 7.6.1 Representation Clauses
Address any questions or comments to email@example.com.