Difference between revisions of "Local variable"

From Computer History Wiki
Jump to: navigation, search
(An OK stub)
 
m (+cat)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
A '''local variable''' (also called '''automatic storage''', etc) in a [[programming language]] is one that only has storage allocated for it when the [[subroutine|procedure]] in which the variable is defined is entered, during the execution of the [[program]]. Once that particular invocation of the procedure is exited, the values of all the automatic variables in it disappear.
+
A '''local variable''' (also called '''automatic storage''', etc) in a [[programming language]] is one that only has storage allocated for it when the [[subroutine|procedure]] or [[control flow|block]] in which the variable is defined is entered, during the execution of the [[program]]. Once that particular invocation of the procedure or block is exited, the values of all the automatic variables in it disappear.
  
Automatic variables are usually implemented with a [[stack]].
+
Automatic variables are usually implemented with a [[stack]]. Also, they usually have a [[scope]] which is restricted to the procedure or block.
  
{{stub}}
+
{{semi-stub}}
 +
 
 +
[[Category: Software Basics]]

Latest revision as of 22:41, 16 December 2018

A local variable (also called automatic storage, etc) in a programming language is one that only has storage allocated for it when the procedure or block in which the variable is defined is entered, during the execution of the program. Once that particular invocation of the procedure or block is exited, the values of all the automatic variables in it disappear.

Automatic variables are usually implemented with a stack. Also, they usually have a scope which is restricted to the procedure or block.