The Ada Program: over.adb

  1 -- over.adb:  a procedure illustrating overloaded enumeration types
  2 
  3 with Ada.Text_IO;
  4 use Ada;
  5 
  6 procedure Over is
  7 
  8    -- from Cohen, Section 3.11, page 145-146
  9    type Suit_Type is (Clubs, Diamonds, Hearts, Spades);
 10    type Commodity_Type is (Pork_Bellies, Wheat, Silver, Diamonds, Gold);
 11    type A_Type is (A, 'A', 'Z', 'a');
 12 
 13    package Suit_IO is new Text_IO.Enumeration_IO (Suit_Type);
 14    package Commodity_IO is new Text_IO.Enumeration_IO (Commodity_Type);
 15 
 16    Longest_Suit : Suit_Type := Diamonds;   -- not ambiguous
 17 
 18 begin
 19 
 20    -- for X in Diamonds .. Diamonds loop
 21    --   null;
 22    -- end loop;
 23 
 24    -- Use a qualified expression to communicate the literal of the
 25    -- desired type.
 26    for X in Suit_Type'(Diamonds) .. Diamonds loop
 27       null;
 28    end loop;
 29 
 30    for X in Suit_Type range Diamonds .. Diamonds loop
 31      null;
 32    end loop;
 33 
 34    for X in Character range 'A' .. 'Z' loop
 35       null;
 36    end loop;
 37 
 38    for X in Wide_Character range 'A' .. 'Z' loop
 39       null;
 40    end loop;
 41 
 42    for X in A_Type range 'A' .. 'Z' loop
 43       null;
 44    end loop;
 45 
 46 end Over;