1 [{enumeration type} An enumeration_type_definition defines an enumeration type.]
2 enumeration_type_definition ::=
(enumeration_literal_specification {, enumeration_literal_specification})
3 enumeration_literal_specification ::= defining_identifier | defining_character_literal
4 defining_character_literal ::= character_literal
5 [The defining_identifiers and defining_character_literals listed in an enumeration_type_definition shall be distinct.]
5.a Proof: This is a ramification of the normal disallowance of homographs explicitly declared immediately in the same declarative region.
6 {enumeration literal} Each enumeration_literal_specification is the explicit declaration of the corresponding enumeration literal: it declares a parameterless function, whose defining name is the defining_identifier or defining_character_literal, and whose result type is the enumeration type.
6.a Reason: This rule defines the profile of the enumeration literal, which is used in the various types of conformance.
6.b Ramification: The parameterless function associated with an enumeration literal is fully defined by the enumeration_type_definition; a body is not permitted for it, and it never fails the Elaboration_Check when called.
7 Each enumeration literal corresponds to a distinct value of the enumeration type, and to a distinct position number. {position number (of an enumeration value) [partial]} The position number of the value of the first listed enumeration literal is zero; the position number of the value of each subsequent enumeration literal is one more than that of its predecessor in the list.
8 [The predefined order relations between values of the enumeration type follow the order of corresponding position numbers.]
9 [{overloaded (enumeration literal) [partial]} If the same defining_identifier or defining_character_literal is specified in more than one enumeration_type_definition, the corresponding enumeration literals are said to be overloaded. At any place where an overloaded enumeration literal occurs in the text of a program, the type of the enumeration literal has to be determinable from the context (see 8.6).]
10 {elaboration (enumeration_type_definition) [partial]} {constrained (subtype)} {unconstrained (subtype)} The elaboration of an enumeration_type_definition creates the enumeration type and its first subtype, which is constrained to the base range of the type.
10.a Ramification: The first subtype of a discrete type is always constrained, except in the case of a derived type whose parent subtype is Whatever'Base.
11 When called, the parameterless function associated with an enumeration literal returns the corresponding value of the enumeration type.
NOTES
12 (24) If an enumeration literal occurs in a context that does not otherwise suffice to determine the type of the literal, then qualification by the name of the enumeration type is one way to resolve the ambiguity (see 4.7).
13 Examples of enumeration types and subtypes:
14
15
16
16.a The syntax rule for defining_character_literal is new. It is used for the defining occurrence of a character_literal, analogously to defining_identifier. Usage occurrences use the name or selector_name syntactic categories.
16.b We emphasize the fact that an enumeration literal denotes a function, which is called to produce a value.