-- This is the generic implementation for a stack abstract data type.

package body StackPkg is

   function IsEmpty (S : Stack) return Boolean is
   begin
      return S.Top = 0;
   end IsEmpty;

   ...

   procedure Push (Item : ItemType; S : in out Stack) is
      --  Precondition guarantees that s is not full
   begin
         S.Top := S.Top + 1;
         S.Elements(S.Top) := Item;
   end Push;

   ...

end StackPkg;