Please note that the content of this book primarily consists of articles
available from Wikipedia or other free sources online. In computer
science, a local variable is a variable that is given local scope. Such
a variable is accessible only from the function or block in which it is
declared. In programming languages with only two levels of visibility,
local variables are contrasted with global variables, on the other hand,
many ALGOL-derived languages allow any number of levels of nested
functions with private variables, functions, constants and types hidden
within them. In most languages, local variables are automatic variables
stored on the call stack directly. This means that when a recursive
function calls itself, local variables in each instance of the function
are given separate memory address space. Hence variables of this scope
can be declared, written to, and read, without any risk of side-effects
to processes outside of the block in which they are declared.
Programming languages that employ call by value semantics provide a
called subroutine with its own local copy of the arguments passed to it.
In most languages, these local parameters are treated the same as other
local variables within the subroutine.