The term
spaghetti stack is closely associated with implementations of
programming languages that support
continuations. Spaghetti stacks are used to implement the actual
run-time stack containing variable bindings and other environmental features. When continuations must be supported, a function's local variables cannot be destroyed when that function returns: a saved continuation may later re-enter into that function, and will expect not only the variables there to be intact, but it will also expect the entire stack to be present so the function is able to return again. To resolve this problem,
stack frames can be
dynamically allocated in a spaghetti stack structure, and simply left behind to be
garbage collected when no continuations refer to them any longer. This type of structure also solves both the upward and downward
funarg problems, as a result first-class lexical
closures are readily implemented in that substrate. Examples of languages that use spaghetti stacks are: • Languages having first-class continuations such as
Scheme and
Standard ML of New Jersey • Languages where the execution stack can be inspected and modified at runtime such as •
Smalltalk •
Felix •
Cilk Mainframe computers using the
instruction set architecture of the Burroughs B6500 and its successors, running the
MCP operating system, can spawn multiple tasks within the same program. Since these were originally
ALGOL-based systems they have to support
nested functions and the result is that task creation results in a fork in the stack, which
Burroughs informally described as a "saguaro stack.". ==See also==