Learn English – How should I write “push onto/on (the) stack”

meaning-in-contextsentence-constructionword-usage

I would like to know which of the following expressions are not correct and why:

  1. push onto the stack
  2. push onto stack
  3. push on the stack
  4. push on stack

Is there a good guide or rule on how to use onto?

Best Answer

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).

Related Topic