Static Local Variables
A special type of local variable, called a static local, is available in many mainstream languages (including C/C++, Visual Basic, and VB.NET) which allows a value to be retained from one call of the function to another. In this case, recursive calls to the function also have access to the (single, statically allocated) variable. In all of the above languages, static variables are declared as such with a special storage class keyword (e.g., static
).
Static locals in global functions can be thought of as global variables, because their value remains in memory for the life of the program. The only difference is that they are only accessible (i.e., scoped) to one function.
This is distinct from other usages of the static
keyword, which has several different meanings in various languages.
Read more about this topic: Local Variable
Famous quotes containing the words local and/or variables:
“Wags try to invent new stories to tell about the legislature, and end by telling the old one about the senator who explained his unaccustomed possession of a large roll of bills by saying that someone pushed it over the transom while he slept. The expression It came over the transom, to explain any unusual good fortune, is part of local folklore.”
—For the State of Montana, U.S. public relief program (1935-1943)
“The variables of quantification, something, nothing, everything, range over our whole ontology, whatever it may be; and we are convicted of a particular ontological presupposition if, and only if, the alleged presuppositum has to be reckoned among the entities over which our variables range in order to render one of our affirmations true.”
—Willard Van Orman Quine (b. 1908)