Prev | Up | Next | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help


13.4 Enumeration Representation Clauses

(1)
An enumeration_representation_clause specifies the internal codes for enumeration literals.
Syntax
(2)
       enumeration_representation_clause ::=
           for first_subtype_local_name use enumeration_aggregate;
(3)
       enumeration_aggregate ::= array_aggregate
Name Resolution Rules
(4)
The enumeration_aggregate shall be written as a one-dimensional array_aggregate, for which the index subtype is the unconstrained subtype of the enumeration type, and each component expression is expected to be of any integer type.
Legality Rules
(5)
The first_subtype_local_name of an enumeration_representation_clause shall denote an enumeration subtype.
(6)
The expressions given in the array_aggregate shall be static, and shall specify distinct integer codes for each value of the enumeration type; the associated integer codes shall satisfy the predefined ordering relation of the type.
Static Semantics
(7)
An enumeration_representation_clause specifies the coding aspect of representation. The coding consists of the internal code for each enumeration literal, that is, the integral value used internally to represent each literal.
Implementation Requirements
(8)
For nonboolean enumeration types, if the coding is not specified for the type, then for each value of the type, the internal code shall be equal to its position number.
Implementation Advice
(9)
The recommended level of support for enumeration_representation_clauses is:
(10)

(11)
Examples
(12)
Example of an enumeration representation clause:
(13)
       type Mix_Code is (ADD, SUB, MUL, LDA, STA, STZ);
(14)
       for Mix_Code use
          (ADD => 1, SUB => 2, MUL => 3, LDA => 8, STA => 24, STZ =>33);


Prev | Up | Next | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help

Ada WWW Home -- Email comments, additions, corrections, gripes, kudos, etc. to:

Magnus Kempe -- Magnus.Kempe@di.epfl.ch
Copyright statement
Page last generated: 95-03-12