I would like to know which of the following expressions are not correct and why:
- push onto the stack
- push onto stack
- push on the stack
- push on stack
Is there a good guide or rule on how to use onto?
In programming contexts, the idiomatic phrase is "push onto the stack".
The stack is a metaphor, like a stack of poker chips. A poker chip is put onto the stack of chips, that is, placed on the top of the stack.
In real life, we usually remove the topmost item from a stack when we need to take an item from one. Hence its applicability to last-in-first-out programming scenarios. It's the opposite of a so-called FIFO queue (first in first out).