--  Generic forms (RM 8.5.5, 12.6, 12.7): a formal subprogram `is abstract`, whose calls
--  dispatch; a formal package with some actuals named and `others => <>`; generic
--  renamings, local and as a library unit.
with Ada.Text_IO;
with Shapes; use Shapes;
with Exchange;
procedure Main is
   generic
      type T is abstract tagged private;
      with function Id (X : T) return Integer is abstract;
   package Holders is
      function Get (X : T'Class) return Integer is (Id (X));
   end Holders;
   package H is new Holders (Base, Id);

   generic
      type T is private;
      Default : T;
   package Boxes is
      function Get return T is (Default);
   end Boxes;
   generic
      with package B is new Boxes (T => Integer, others => <>);
   function Read_Int return Integer;
   function Read_Int return Integer is (B.Get);
   package Int_Box is new Boxes (Integer, 3);
   function RI is new Read_Int (Int_Box);

   generic package Containers renames Boxes;
   package Five is new Containers (Integer, 5);
   procedure Swap_Integers is new Exchange (Integer);

   L : Leaf;
   W : Twig;
   X : Integer := 1;
   Y : Integer := 2;
begin
   Ada.Text_IO.Put_Line (Integer'Image (H.Get (L)) & Integer'Image (H.Get (W)));
   Ada.Text_IO.Put_Line (Integer'Image (RI) & Integer'Image (Five.Get));
   Swap_Integers (X, Y);
   Ada.Text_IO.Put_Line (Integer'Image (X) & Integer'Image (Y));
end Main;
