package body stacks is type stack_node is record head:Item; rest:stack; end record; function newstack return Stack is begin return NULL; end newstack; function pop( the_stack:Stack) return Stack is the_head:Stack; begin if empty(the_stack) then raise stack_empty; else return the_stack.rest; end if; end pop; function push( the_stack:Stack; an_item:Item) return Stack is begin return new stack_node'(head=>an_item, rest=>the_stack); end push; function top( the_stack: Stack) return Item is begin if empty(the_stack) then raise stack_empty; else return the_stack.head; end if; end top; function empty( the_stack:Stack) return Boolean is begin return the_stack=NULL; end empty; end stacks;