Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use <a href="/questions/tagged/stack-pointer" class="post-tag" title="show questions tagged &#39;stack-pointer&#39;" rel="tag">stack-pointer</a> or <a href="/questions/tagged/callstack" class="post-tag" title="show questions tagged &#39;callstack&#39;" rel="tag">callstack</a> for questions about the <a href="https://en.wikipedia.org/wiki/Call_stack" rel="nofollow noreferrer">call-stack</a>.</p> <p>Use this tag only for questions about other stacks, used for your own data.</p> <hr> <p>A <a href="http://en.wikipedia.org/wiki/Stack_%28data_structure%29" rel="nofollow noreferrer">stack</a> is a data structure, often used as an abstract data type (ADT) in many programming languages, to store data in a last in, first out (LIFO) manner. You could imagine it like a stack of cards. If you put a card onto the top of the stack, and then take the top card off the stack, you'll get the same card you put onto it.</p> <p>Putting data onto a stack is called pushing. Taking something from a stack is called popping. Checking what's on top of a stack without removing it is called peaking.</p> <p>Here is an example program:</p> <pre><code>a = new stack() a.push(5) b = a.peak() print(b) a.push(6) b = a.pop() print(b) b = a.pop() print(b) </code></pre> <p>would give the output:</p> <pre><code>5 6 5 </code></pre> <p>The <a href="/questions/tagged/callstack" class="post-tag" title="show questions tagged &#39;callstack&#39;" rel="tag">callstack</a> is a stack data structure that's used to keep track of local variables and allows easy nested function calls (including for recursive functions). The current top-of-stack is usually tracked by a dedicated <a href="/questions/tagged/stack-pointer" class="post-tag" title="show questions tagged &#39;stack-pointer&#39;" rel="tag">stack-pointer</a> register. Different CPU architectures and calling conventions manage the stack differently, but it's common to push a return address as part of calling a function. Returning pops the return address and jumps to it, allowing a function to return to wherever it was called from.</p> <p><strong>Related tags:</strong></p> <ul> <li><a href="/questions/tagged/stack-overflow" class="post-tag" title="show questions tagged &#39;stack-overflow&#39;" rel="tag">stack-overflow</a> an error from using <code>push()</code> on a full stack</li> <li><a href="/questions/tagged/stackunderflow" class="post-tag" title="show questions tagged &#39;stackunderflow&#39;" rel="tag">stackunderflow</a> an error from using <code>pop()</code> on an empty stack</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload