-- Chapter 30 - Program 1 generic type ITEM is range <>; -- integer class only procedure Exchange_Data(X,Y : in out ITEM); procedure Exchange_Data(X,Y : in out ITEM) is Temp : ITEM; begin Temp := X; X := Y; Y := Temp; end Exchange_Data; -- This is the beginning of the main program which uses the generic -- procedure defined above. with Exchange_Data; with Ada.Text_IO, Ada.Integer_Text_IO; use Ada.Text_IO, Ada.Integer_Text_IO; procedure SwapSome is type MY_INT is new INTEGER range 1..128; procedure SwapInt is new Exchange_Data(INTEGER); procedure SwapNew is new Exchange_Data(MY_INT); Index1 : INTEGER := 17; Index2 : INTEGER := 33; Limit1 : MY_INT := 3; Limit2 : MY_INT := 7; begin SwapInt(Index1, Index2); SwapNew(Limit1, Limit2); Put(Index1, 5); Put(Index2, 5); New_Line; Put(INTEGER(Limit1), 5); Put(INTEGER(Limit2), 5); New_Line(2); SwapInt(Index1, INTEGER(Limit1)); SwapNew(MY_INT(Index2), Limit2); Put(Index1, 5); Put(Index2, 5); New_Line; Put(INTEGER(Limit1), 5); Put(INTEGER(Limit2), 5); New_Line(2); end SwapSome; -- Result of Execution -- 33 17 -- 7 3 -- -- 7 3 -- 33 17