generic stack, implemented using a singly-linked list