with ada.text_io; use ada.text_io;
with ada.integer_text_io; use ada.integer_text_io;
-- Generic packages
with stackpkg;
with stackpkg.utils;
procedure trystack2 is
-- This method is defined so that we can pass it to the generic
procedure myIntPut(i: integer) is
begin
ada.integer_text_io.put(i);
end myIntPut;
-- Instantiate generic package for integers
package intstack is new stackpkg(100, integer);
use intstack;
-- Instantiate child generic package for integers
-- Pass in myIntPut to print an integer
package intstackutils is
new intstack.utils(print_item => myIntPut);
use intstackutils;
-- We can't pass ada.integer_text_io above directly because it has
-- default parameters (ie it has three, not one, parameter)
-- so we pass myIntPut which has one param, which matches the
-- generic parameter
s: intstack.stack;
begin
push(10, s);
push(20, s);
intstackutils.print_stack (s); new_line;
put_line(size(s)'img);
pop(s);
print_stack (s); new_line;
end trystack2;