Ada Conformity Assessment Authority      Home Conformity Assessment   Test Suite ARGAda Standard
Overview of Ada 2022
Jeff Cousins
Contents   Index   Search   Previous   Next 

7.6 Aggregates and variant parts

Aggregates and variant parts (AI12-0086) allows a discriminant that controls a variant in an aggregate to be non-static if the subtype of the discriminant is static and all values belonging to that subtype select the same variant (see RM 4.3.1). For example:
type Enum is (Aa, Bb, Cc, ..., Zz);
subtype S is Enum range Dd .. Hh;
type Rec (D : Enum) is record
   case D is
      when S => Foo, 
         Bar : Integer;
      when others => 
   end case;
end record;
function Make (D : S) return Rec is
   return (D => D, Foo => 123, Bar => 456);

Contents   Index   Search   Previous   Next 
© 2021, 2022 Jeff Cousins