Call Stack as Stack of Papers

Programming Language

imperative / any

Form

Analogy

Attribution — Origin / Source

Collected by Matthias Hauswirth — Interview, Antonio Carzaniga

Conceptual Advantage

Makes concrete the workings of a call 'stack' (push/pop stack frames), and the notion of a 'stack frame'.

Mapping

PLNM
call stack stack of papers
stack frame sheet of paper
local variable line of text on a sheet
call push a sheet on top of the stack
return pop the top sheet off the stack

Draws Attention To

The call stack.

Use When

When introducing calls and returns, and the lifetime of local variables.

Cost

Need papers, time to draw contents of each stack frame. Contents of stack frame not easily visible to students unless teacher holds up the stack (or uses a flip chart).

Comments or Feedback?

Do you have feedback on this notional machine? Did you find a mistake, or do you have a request for improvement? You can create an Issue on GitHub, where the description is hosted. This way we can see your feedback and address it.

For this, you need a GitHub account. Then follow this link to see the source file of this page. In there, click the ... left of the highlighted line, then pick "Reference in a new issue".

Create an Issue on GitHub