I have 2 issues with the code below:
Should I throw an exception if pop()
I won't talk about the list structure as that's already been covered in this question. Instead I'll mention my preferred method for dealing with stacks:
I always use the Queue
module. It supports FIFO and LIFO data structures and is thread safe.
See the docs for more info. It doesn't implement a isEmpty()
function, it instead raises a Full
or Empty
exception if a push or pop can't be done.