3.8.1 Variant Parts and Discrete Choices
Syntax
Name Resolution Rules
Legality Rules
The discriminant of the 
variant_part 
shall be of a discrete type. 
 
The possible values 
of the discriminant of a 
variant_part 
shall be covered as follows: 
 
If the discriminant is of a static constrained 
scalar subtype then, except within an instance of a generic unit, each 
non-
others discrete_choice 
shall cover only values in that subtype that satisfy its predicates, 
and each value of that subtype that satisfies its predicates shall be 
covered by some 
discrete_choice 
(either explicitly or by 
others);
 
If the type of the discriminant is a descendant 
of a generic formal scalar type, then the 
variant_part 
shall have an 
others discrete_choice; 
 
Otherwise, each value of the base range of the 
type of the discriminant shall be covered (either explicitly or by others). 
Static Semantics
Dynamic Semantics
Examples
Example of record 
type with a variant part: 
type Device is (Printer, Disk, Drum);
type State  is (Open, Closed);
type Peripheral(Unit : Device := Disk) is
   record
      Status : State;
      case Unit is
         when Printer =>
            Line_Count : Integer range 1 .. Page_Size;
         when others =>
            Cylinder   : Cylinder_Index;
            Track      : Track_Number;
         end case;
      end record;
Examples of record 
subtypes: 
subtype Drum_Unit is Peripheral(Drum);
subtype Disk_Unit is Peripheral(Disk);
Examples of constrained 
record variables: 
Writer   : Peripheral(Unit  => Printer);
Archive  : Disk_Unit;
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe