Please note that the content of this book primarily consists of articles
available from Wikipedia or other free sources online. In computer
science, a call stack is a stack data structure that stores information
about the active subroutines of a computer program. This kind of stack
is also known as an execution stack, control stack, function stack, or
run-time stack, and is often shortened to just "the stack". Although
maintenance of the call stack is important for the proper functioning of
most software, the details are normally transparent in high-level
programming languages. A call stack is used for several related
purposes, but the main reason for having one is to keep track of the
point to which each active subroutine should return control when it
finishes executing. (The active subroutines are those which have been
called but have not yet completed execution by returning.) If, for
example, a subroutine DrawSquare calls a subroutine DrawLine from four
different places, the code of DrawLine must have a way of knowing where
to return. This is typically done by code for each call within
DrawSquare putting the address of the instruction after the particular
call statement (the "return address") onto the call stack.