local variable


local variable

[′lō·kəl ′ver·ē·ə·bəl] (computer science) A variable which can be accessed (used or changed) only in one block of a computer program.

local variable

(programming)A variable with lexical scope, i.e. onewhich only exists in some particular part of the source code, typically within a block or a function orprocedure body. This contrasts with a global variable,which is defined throughout the whole program.

Code is easier to understand when the scope of variables is assmall as possible because it is easier to see how the variableis set and used. Code containing global variables is harderto modify because they create more interdependencies betweensections of code.

local variable

In programming, a variable used only within the routine or function it is defined in. When the function is finished and control is returned back to the part of the program that called it, the local variables no longer exist. Contrast with global variable.