Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Static variable
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==History== Static variables date at least to [[ALGOL 60]] (1960), where they are known as '''''own''' variables'': {{quote |A declaration may be marked with the additional declarator '''own.''' This has the following effect: upon a re-entry into the block, the values of '''own''' quantities will be unchanged from their values at the last exit, while the values of declared variables that are not marked with '''own''' is undefined. |Revised report on ALGOL 60, section "5. Declarations", p. 14}} This definition is subtly different from a static variable: it only specifies behavior, and hence lifetime, not storage: an own variable can be allocated when a function is first called, for instance, rather than at program load time. The use of the word ''static'' to refer to these variables dates at least to [[BCPL]] (1966), and has been popularized by the [[C programming language]], which was heavily influenced by BCPL. The BCPL definition reads: {{quote |(1) Static data items:<br>Those data items whose extents lasts as long as the program execution time; such data items have manifest constant Lvalues. Every static data item must have been declared either in a function or routine definition, in a global declaration or as a label set by colon. |The BCPL Reference Manual, 7.2 Space Allocation and Extent of Data Items}} Note that BCPL defined a "dynamic data item" for what is now called an ''automatic'' variable (local, stack-allocated), not for heap-allocated objects, which is the current use of the term ''dynamic allocation''. The [[Static (keyword)|<code>static</code> keyword]] is used in C and related languages both for static variables and other concepts.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)