Counting_pine really takes the lead in shortness and amount of magic :)
KristopherWindsor wrote:I know that can be done, but it's 22 lines vs. my 12.
I hate to repeat myself, but your implementation scales really badly: do a couple of more pops and you have longer code than mine and what's worse, code is duplicated. Also, my push is much shorter to write although the line count in that is the same. In addition, I find it a really bad design decision to try to shave off a couple of lines in the user-invisible type code with the cost of usability - especially when a nice interface can be implemented with even less lines as counting_pine has proved (I don't say my implementation is near perfect, I'm trying to make a point of the clunkyness of your interface).
If you were programming for some embedded microcontroller where you need to be the most space efficient, you would be using an array instead of a pointer list, not too differently from what counting_pine is doing.
KristopherWindsor wrote:My solution can be re-implemented quickly for whatever data type you're working with
The stack should be wrapped inside a macro that regenerates the Type for appropriate data types (i.e. replace Integer with a macro parameter and append the typename to the stack's typename). Then if you change the stack implementation, you don't have to keep several different implementations in sync as the compiler takes care of that.