Content deleted Content added
m Bot: Migrating 1 interwiki links, now provided by Wikidata on d:q1091711 |
elab local, lifetime vs. context vs. scope |
||
Line 1:
__NOTOC__
In [[computer programming]], an '''automatic variable''' is a
The term ''[[local variable]]'' is usually synonymous with automatic variable, since these are the same thing in many programming languages, but local is more general – most local variables are automatic local variables, but [[static local variable]]s also exist, notably in C. For a static local variable, the allocation is static (the lifetime is the entire program execution), not automatic, but it is only in scope during the execution of the function.
Automatic variables may be [[Stack-based memory allocation|allocated in the stack frame]] of the procedure in which they are declared; this has the useful effect of allowing [[recursion]] and [[reentrant (subroutine)|re-entrancy]]. (For efficiency, the [[compiler optimization|optimizer]] will try to allocate some of these variables in [[processor register]]s.)
|