imperative / any
Analogy
Collected by Matthias Hauswirth — Interview, Antonio Carzaniga
Makes concrete the workings of a call 'stack' (push/pop stack frames), and the notion of a 'stack frame'.
PL | NM |
---|---|
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 |
The call stack.
When introducing calls and returns, and the lifetime of local variables.
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).
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".