Knowledge

Scope (computer science)

Source đź“ť

2746:, but if it is used that way it cannot be based on saving and restoring a global variable. A possible implementation strategy is for each variable to have a thread-local key. When the variable is accessed, the thread-local key is used to access the thread-local memory location (by code generated by the compiler, which knows which variables are dynamic and which are lexical). If the thread-local key does not exist for the calling thread, then the global location is used. When a variable is locally bound, the prior value is stored in a hidden location on the stack. The thread-local storage is created under the variable's key, and the new value is stored there. Further nested overrides of the variable within that thread simply save and restore this thread-local location. When the initial, outermost override's context terminates, the thread-local key is deleted, exposing the global version of the variable once again to that thread. 2739:
restored from this location. In fact, dynamic scope originated in this manner. Early implementations of Lisp used this obvious strategy for implementing local variables, and the practice survives in some dialects which are still in use, such as GNU Emacs Lisp. Lexical scope was introduced into Lisp later. This is equivalent to the above shallow binding scheme, except that the central reference table is simply the global variable binding context, in which the current meaning of the variable is its global value. Maintaining global variables isn't complex. For instance, a symbol object can have a dedicated slot for its global value.
3112:. There are three types of lifetimes in C: static (program execution), automatic (block execution, allocated on the stack), and manual (allocated on the heap). Only static and automatic are supported for variables and handled by the compiler, while manually allocated memory must be tracked manually across different variables. There are three levels of visibility in C: external linkage (global), internal linkage (roughly file), and block scope (which includes functions); block scopes can be nested, and different levels of internal linkage is possible by use of includes. Internal linkage in C is visibility at the 557:)—a name can only refer to a variable that exists (possibly with undefined value), but variables that exist are not necessarily visible: a variable may exist but be inaccessible (the value is stored but not referred to within a given context), or accessible but not via the given name, in which case it is not in context (the program is "out of the scope of the name"). In other cases "lifetime" is irrelevant—a label (named position in the source code) has lifetime identical with the program (for statically compiled languages), but may be in context or not at a given point in the program, and likewise for 584:), and varies between languages. Given a name, the language (properly, the compiler or interpreter) checks all entities that are in context for matches; in case of ambiguity (two entities with the same name, such as a global and local variable with the same name), the name resolution rules are used to distinguish them. Most frequently, name resolution relies on an "inner-to-outer context" rule, such as the Python LEGB (Local, Enclosing, Global, Built-in) rule: names implicitly resolves to the narrowest relevant context. In some cases name resolution can be explicitly specified, such as by the 648:
anywhere in the program, and local scope within a function. More sophisticated modular programming allows a separate module scope, where names are visible within the module (private to the module) but not visible outside it. Within a function, some languages, such as C, allow block scope to restrict scope to a subset of a function; others, notably functional languages, allow expression scope, to restrict scope to a single expression. Other scopes include file scope (notably in C) which behaves similarly to module scope, and block scope outside of functions (notably in Perl).
3043: 36: 3994:
exception. If a variable is simply accessed (not assigned to), name resolution follows the LEGB (Local, Enclosing, Global, Built-in) rule which resolves names to the narrowest relevant context. However, if a variable is assigned to, it defaults to declaring a variable whose scope starts at the start of the level (function, module, or global), not at the assignment. Both these rules can be overridden with a
3610:, but variable initialization and name resolution rules can cause problems, and the widespread use of closures for callbacks means the lexical context of a function when defined (which is used for name resolution) can be very different from the lexical context when it is called (which is irrelevant for name resolution). JavaScript objects have name resolution for properties, but this is a separate topic. 1681:(internal linking). This can be seen as a form of module scope, where modules are identified with files, and in more modern languages is replaced by an explicit module scope. Due to the presence of include statements, which add variables and functions to the internal context and may themselves call further include statements, it can be difficult to determine what is in context in the body of a file. 1074:, shadowing the parameter name, but this is considered poor style due to the potential for errors. Furthermore, some descendants of C, such as Java and C#, despite having support for block scope (in that a local variable can be made to go out of context before the end of a function), do not allow one local variable to hide another. In such languages, the attempted declaration of the second 1749:—are frequently considered bad practice, at least in some languages, due to the possibility of name collisions and unintentional masking, together with poor modularity, and function scope or block scope are considered preferable. However, global scope is typically used (depending on the language) for various other sorts of names, such as names of functions, names of 362:). In practice, with lexical scope a name is resolved by searching the local lexical context, then if that fails, by searching the outer lexical context, and so on; whereas with dynamic scope, a name is resolved by searching the local execution context, then if that fails, by searching the outer execution context, and so on, progressing up the call stack. 1052:
purpose is to allow fine-grained control of variable scope. For example, an auxiliary variable may be defined in a block, then used (say, added to a variable with function scope) and discarded when the block ends, or a while loop might be enclosed in a block that initializes variables used inside the loop that should only be initialized once.
1063:), is that block-scope variables can be declared not only within the body of the block, but also within the control statement, if any. This is analogous to function parameters, which are declared in the function declaration (before the block of the function body starts), and in scope for the whole function body. This is primarily used in 527:. Strictly speaking, during execution a program enters and exits various name bindings' scopes, and at a point in execution name bindings are "in context" or "not in context", hence name bindings "come into context" or "go out of context" as the program execution enters or exits the scope. However, in practice usage is much looser. 1797:), if a variable name's scope is a certain function, then its scope is the time-period during which the function is executing: while the function is running, the variable name exists, and is bound to its value, but after the function returns, the variable name does not exist. This means that if function 3993:
For variables, Python has function scope, module scope, and global scope. Names enter context at the start of a scope (function, module, or global scope), and exit context when a non-nested function is called or the scope ends. If a name is used prior to variable initialization, this raises a runtime
3323:
All the variables that we intend to use in a program must have been declared with its type specifier in an earlier point in the code, like we did in the previous code at the beginning of the body of the function main when we declared that a, b, and result were of type int. A variable can be either of
2560:
Most LISP implementations are internally inconsistent in that by default the interpreter and compiler may assign different semantics to correct programs; this stems primarily from the fact that the interpreter assumes all variables to be dynamically scoped, while the compiler assumes all variables to
1730:
rather than name resolution and scope, though they often play analogous roles. In some cases both these facilities are available, such as in Python, which has both modules and classes, and code organization (as a module-level function or a conventionally private method) is a choice of the programmer.
3639:
While JavaScript scope is simple—lexical, function-level—the associated initialization and name resolution rules are a cause of confusion. Firstly, assignment to a name not in scope defaults to creating a new global variable, not a local one. Secondly, to create a new local variable one must use the
2775:
is a key example of de facto dynamic scope. The macro language itself only transforms the source code, without resolving names, but since the expansion is done in place, when the names in the expanded text are then resolved (notably free variables), they are resolved based on where they are expanded
3895:
nested scopes of the current lexical context, or "scope chain"); this may be accidental. When creating a callback based on parameters, the parameters must be stored in a closure, otherwise it will accidentally create a closure that refers to the variables in the enclosing context, which may change.
1660:
Function scope is significantly more complicated if functions are first-class objects and can be created locally to a function and then returned. In this case any variables in the nested function that are not local to it (unbound variables in the function definition, that resolve to variables in an
3760:
can be produced in JavaScript by using nested functions, as functions are first-class objects. Returning a nested function from an enclosing function includes the local variables of the enclosing function as the (non-local) lexical context of the returned function, yielding a closure. For example:
3749:
Further, as functions are first-class objects in JavaScript and are frequently assigned as callbacks or returned from functions, when a function is executed, the name resolution depends on where it was originally defined (the lexical context of the definition), not the lexical context or execution
3480:
are defined inside a method, or a particular block. These variables are local to where they were defined and lower levels. For example, a loop inside a method can use that method's local variables, but not the other way around. The loop's variables (local to that loop) are destroyed as soon as the
2230:
and its syntactic and semantic relatives, although with different kinds of limitations. Static scope allows the programmer to reason about object references such as parameters, variables, constants, types, functions, etc. as simple name substitutions. This makes it much easier to make modular code
1422:
of the function: it goes out of context when another function is called within the function, and comes back into context when the function returns—called functions have no access to the local variables of calling functions, and local variables are only in context within the body of the function in
651:
A subtle issue is exactly when a scope begins and ends. In some languages, such as C, a name's scope begins at the name declaration, and thus different names declared within a given block can have different scopes. This requires declaring functions before use, though not necessarily defining them,
647:
Scope can vary from as little as a single expression to as much as the entire program, with many possible gradations in between. The simplest scope rule is global scope—all entities are visible throughout the entire program. The most basic modular scope rule is two-level scope, with a global scope
3894:
Closures are frequently used in JavaScript, due to being used for callbacks. Indeed, any hooking of a function in the local context as a callback or returning it from a function creates a closure if there are any unbound variables in the function body (with the context of the closure based on the
3138:
In C, variables with block scope enter context when they are declared (not at the top of the block), go out of context if any (non-nested) function is called within the block, come back into context when the function returns, and go out of context at the end of the block. In the case of automatic
2682:
for (or circumstances of) a variable's value, but simply use the value according to the variable's definition. This narrow interpretation of shared data can provide a very flexible system for adapting the behavior of a function to the current state (or policy) of the system. However, this benefit
2673:
are defined to create bindings whose lifetime is the execution time of the block; this adds some features of static scope to the dynamic scope process. However, since a section of code can be called from many different locations and situations, it can be difficult to determine at the outset what
1051:
Blocks are primarily used for control flow, such as with if, while, and for loops, and in these cases block scope means the scope of variable depends on the structure of a function's flow of execution. However, languages with block scope typically also allow the use of "naked" blocks, whose sole
4194:
Assignment to a variable within a function causes it to be declared local to the function, hence its scope is the entire function, and thus using it prior to this assignment raises an error. This differs from C, where the scope of the local variable start at its declaration. This code raises an
2973:
To address this, many languages offer mechanisms for organizing global names. The details of these mechanisms, and the terms used, depend on the language; but the general idea is that a group of names can itself be given a name — a prefix — and, when necessary, an entity can be referred to by a
2561:
be local unless forced to assume otherwise. This has been done for the sake of convenience and efficiency, but can lead to very subtle bugs. The definition of Common LISP avoids such anomalies by explicitly requiring the interpreter and compiler to impose identical semantics on correct programs.
3314:
There are other levels of scope in C. Variable names used in a function prototype have function prototype visibility, and exit context at the end of the function prototype. Since the name is not used, this is not useful for compilation, but may be useful for documentation. Label names for GOTO
1769:
The use of local variables — of variable names with limited scope, that only exist within a specific function — helps avoid the risk of a name collision between two identically named variables. However, there are two very different approaches to answering this question: What does it mean to be
2969:
As we have seen, one of the key reasons for scope is that it helps prevent name collisions, by allowing identical names to refer to distinct things, with the restriction that the names must have separate scopes. Sometimes this restriction is inconvenient; when many different things need to be
2738:
An even simpler implementation is the representation of dynamic variables with simple global variables. The local binding is performed by saving the original value in an anonymous location on the stack that is invisible to the program. When that binding scope terminates, the original value is
656:
in some cases, notably for mutual recursion. In other languages, such as Python, a name's scope begins at the start of the relevant block where the name is declared (such as the start of a function), regardless of where it is defined, so all names within a given block have the same scope. In
2477:. No overhead at all is therefore incurred when using that type of nested function. The same applies to particular parts of a program where nested functions are not used, and, naturally, to programs written in a language where nested functions are not available (such as in the C language). 1407:, created when the function starts (or the variable is declared), destroyed when the function returns—while the scope of the variable is within the function, though the meaning of "within" depends on whether scope is lexical or dynamic. However, some languages, such as C, also provide for 1411:, where the lifetime of the variable is the entire lifetime of the program, but the variable is only in context when inside the function. In the case of static local variables, the variable is created when the program initializes, and destroyed only when the program terminates, as with a 1300:
This is a more significant issue in C, notably for string assignment, as string initialization can automatically allocate memory, while string assignment to an already initialized variable requires allocating memory, a string copy, and checking that these are successful.
1789:), if a variable name's scope is a certain function, then its scope is the program text of the function definition: within that text, the variable name exists, and is bound to the variable's value, but outside that text, the variable name does not exist. By contrast, in 1725:
languages that lack direct support for modules, such as C++ before C++20, a similar structure is instead provided by the class hierarchy, where classes are the basic unit of the program, and a class can have private methods. This is properly understood in the context of
3505:
In general, a set of brackets defines a particular scope, but variables at top level within a class can differ in their behavior depending on the modifier keywords used in their definition. The following table shows the access to members permitted by each modifier.
1677:. File scope is largely particular to C (and C++), where scope of variables and functions declared at the top level of a file (not within any function) is for the entire file—or rather for C, from the declaration until the end of the source file, or more precisely 152:
where the name binding is valid; that is, where the name can be used to refer to the entity. In other parts of the program, the name may refer to a different entity (it may have a different binding), or to nothing at all (it may be unbound). Scope helps prevent
2718:
Dynamic scope is fairly easy to implement. To find an name's value, the program could traverse the runtime stack, checking each activation record (each function's stack frame) for a value for the name. In practice, this is made more efficient via the use of an
297:
A declaration binds a non-blank identifier to a constant, type, variable, function, label, or package. The scope of a declared identifier is the extent of source text in which the identifier denotes the specified constant, type, variable, function, label, or
5368:
Variables defined inside a function cannot be accessed from anywhere outside the function, because the variable is defined only in the scope of the function. However, a function can access all variables and functions defined inside the scope in which it is
2683:
relies on careful documentation of all variables used this way as well as on careful avoidance of assumptions about a variable's behavior, and does not provide any mechanism to detect interference between different parts of a program. Some languages, like
266:
The following kinds of quantities are distinguished: simple variables, arrays, labels, switches, and procedures. The scope of a quantity is the set of statements and expressions in which the declaration of the identifier associated with that quantity is
2731:, which associates each name with its own stack of meanings. This avoids a linear search during run-time to find a particular name, but care should be taken to properly maintain this table. Note that both of these strategies assume a last-in-first-out ( 3678:, rather than a syntax error. Fourthly, for function declarations, the declaration and the initialization are both hoisted to the top of the function, unlike for variable initialization. For example, the following code produces a dialog with output 1605:
variables are completely separate and unrelated, despite having the same name, because they are lexically scoped local variables with function scope: each one's scope is its own, lexically separate function and thus, they don't overlap. Therefore,
3131:. Thus name resolution is split across the compiler, which resolves names within a translation unit (more loosely, "compilation unit", but this is properly a different concept), and the linker, which resolves names across translation units; see 3018:, that combine this with the additional purpose of allowing some names to be visible only to other members of their group. And object-oriented languages often allow classes or singleton objects to fulfill this purpose (whether or not they 1665:, as not only the function itself, but also its context (of variables) must be returned, and then potentially called in a different context. This requires significantly more support from the compiler, and can complicate program analysis. 4726:
where the values of free variables are determined by a set of global variables, while in R they are determined by the context in which the function was created. The scope contexts may be accessed using a variety of features (such as
3613:
JavaScript has lexical scope nested at the function level, with the global context being the outermost context. This scope is used for both variables and for functions (meaning function declarations, as opposed to variables of
842:. As the variable names in the prototype are not referred to (they may be different in the actual definition)—they are just dummies—these are often omitted, though they may be used for generating documentation, for instance. 2231:
and reason about it, since the local naming structure can be understood in isolation. In contrast, dynamic scope forces the programmer to anticipate all possible execution contexts in which the module's code may be invoked.
2978:
consisting of the name plus the prefix. Normally such names will have, in a sense, two sets of scopes: a scope (usually the global scope) in which the qualified name is visible, and one or more narrower scopes in which the
431:
can themselves be in context or not in context (using the usual meaning of the term) in any given part of the program, following the usual rules of variable scope of the language like any other object, and using their own
2606:
serious Lisps in production use at that time were dynamically scoped. No one who hadn't carefully read the Rabbit thesis (written by Guy Lewis Steele Jr. in 1978) believed lexical scope would fly; even the few people who
2472:
functions are used, although there are well-known techniques to mitigate this. Also, for nested functions that only refer to their own arguments and (immediately) local variables, all relative locations can be known at
1439:, local variables are in context for nested functions, since these are within the same lexical context, but not for other functions that are not lexically nested. A local variable of an enclosing function is known as a 280:
name; a label name; a macro name; or a macro parameter. The same identifier can denote different entities at different points in the program. For each different entity that an identifier designates, the identifier is
4466:
can also be used for nested functions. In addition to allowing assignment to a global variable, as in an unnested function, this can also be used to access the global variable in the presence of a nonlocal variable:
3139:
local variables, they are also allocated on declaration and deallocated at the end of the block, while for static local variables, they are allocated at program initialization and deallocated at program termination.
1036:, which is initialized at each iteration. The purpose is to avoid adding variables to the function scope that are only relevant to a particular block—for example, this prevents errors where the generic loop variable 538:, which are a type of reference used in programs more generally. Using the value of a variable when the name is in context but the variable is uninitialized is analogous to dereferencing (accessing the value of) a 210:
In most cases, name resolution based on lexical scope is relatively straightforward to use and to implement, as in use one can read backwards in the source code to determine to which entity a name refers, and in
747:
twice. Some languages with block scope approximate this functionality by offering syntax for a block to be embedded into an expression; for example, the aforementioned Standard ML expression could be written in
207:—but the distinction itself is accurate and precise, and these are the standard respective terms. Lexical scope is the main focus of this article, with dynamic scope understood by contrast with lexical scope. 3324:
global or local scope. A global variable is a variable declared in the main body of the source code, outside all functions, while a local variable is one declared within the body of a function or a block.
870:
families and traditions. Most often this block is contained within a function, thus restricting the scope to a part of a function, but in some cases, such as Perl, the block may not be within a function.
5218:
By contrast, *"a name binding's context", *"a name binding coming into scope" or *"a name binding going out of scope" are all incorrect—a name binding has scope, while a part of a program has context.
440:
rules. In the context of AngularJS, sometimes the term "$ scope" (with a dollar sign) is used to avoid confusion, but using the dollar sign in variable names is often discouraged by the style guides.
5192:"Name resolution" and "name binding" are largely synonymous; narrowly speaking "resolution" determines to which name a particular use of a name refers, without associating it with any meaning, as in 3750:
context where it is called. The nested scopes of a particular function (from most global to most local) in JavaScript, particularly of a closure, used as a callback, are sometimes referred to as the
4319:
resolves to the global variable. It thus can be accessed (as it has already been defined), and assignment assigns to the global variable, rather than declaring a new local variable. Note that no
255:) is unambiguous: lexical scope is "the portion of source code in which a binding of a name with an entity applies". This is virtually unchanged from its 1960 definition in the specification of 497:"Scope" and "context" in particular are frequently confused: scope is a property of a name binding, while context is a property of a part of a program, that is either a portion of source code ( 2577:
In addition, Common LISP offers the following facilities (most of which are borrowed from MacLisp, InterLisp or Lisp Machines Lisp): (...) Fully lexically scoped variables. The so-called "
423:
use the term "scope" to mean something entirely different than how it is used in this article. In those frameworks the scope is just an object of the programming language that they use (
365:
Most modern languages use lexical scope for variables and functions, though dynamic scope is used in some languages, notably some dialects of Lisp, some "scripting" languages, and some
3142:
The following program demonstrates a variable with block scope coming into context partway through the block, then exiting context (and in fact being deallocated) when the block ends:
5322:
Backus, J. W.; Wegstein, J. H.; Van Wijngaarden, A.; Woodger, M.; Bauer, F. L.; Green, J.; Katz, C.; McCarthy, J.; Perlis, A. J.; Rutishauser, H.; Samelson, K.; Vauquois, B. (1960).
2453:
is not trivial, as it requires each function value to carry with it a record of the values of the variables that it depends on (the pair of the function and this context is called a
3493:
are variables declared within the class, outside of any method. By default, these variables are available for all methods within that class and also for all classes in the package.
1085:
If a block is used to set the value of a variable, block scope requires that the variable be declared outside of the block. This complicates the use of conditional statements with
5912:
MacLisp improved on the Lisp 1.5 notion of special variables ... The primary influences on Common Lisp were Lisp Machine Lisp, MacLisp, NIL, S-1 Lisp, Spice Lisp, and Scheme.
1431:
when another function is called, only going out of context when the defining function ends, and thus local variables are in context of the function in which they are defined
4002:(in Python 3) declaration prior to use, which allows accessing global variables even if there is a masking nonlocal variable, and assigning to global or nonlocal variables. 1403:: a variable whose scope ends (that goes out of context) when the function returns. In most cases the lifetime of the variable is the duration of the function call—it is an 675:. Behavior of names in context that have undefined value differs: in Python use of undefined names yields a runtime error, while in JavaScript undefined names declared with 456:. Name resolution (including scope) varies between programming languages, and within a programming language, varies by type of entity; the rules for scope are called 5179:
template engine for Python by default uses both lexical scope (for imports) and dynamic scope (for includes), and allows behavior to be specified with keywords; see
5621: 2595:
had been published and compiler implementations were being attempted. At that time, lexical scope in Lisp was commonly feared to be inefficient to implement. In
709:
allowing a declaration's scope to be a single expression. This is convenient if, for example, an intermediate value is needed for a computation. For example, in
5288: 639:
Scopes are frequently tied to other language constructs and determined implicitly, but many languages also offer constructs specifically for controlling scope.
3105:), and local scope (within a function); within a function scopes can further be nested via block scope. However, standard C does not support nested functions. 1207:
Often this is instead rewritten using multiple assignment, initializing the variable to a default value. In Python (where it is not necessary) this would be:
3930:
used dynamic scope by default in the interpreter and lexical scope by default in compiled code, though compiled code could access dynamic bindings by use of
427:
in case of AngularJS) that is used in certain ways by the framework to emulate dynamic scope in a language that uses lexical scope for its variables. Those
2723:, which is a stack of name/value pairs. Pairs are pushed onto this stack whenever declarations are made, and popped whenever variables go out of context. 1649:
is in context at any given time, as the scopes do not overlap. By contrast, were a similar fragment to be written in a language with dynamic scope, the
2787:, has de facto dynamic scope, as it does not do name resolution by itself and it is independent of where the macro is defined. For example, the macro: 3682:, as the local variable declaration is hoisted, shadowing the global variable, but the initialization is not, so the variable is undefined when used: 2691:, allow the programmer to choose static or dynamic scope when defining or redefining a variable. Examples of languages that use dynamic scope include 157:
by allowing the same name to refer to different objects – as long as the names have separate scopes. The scope of a name binding is also known as the
6029: 1353:
Some languages allow the concept of block scope to be applied, to varying extents, outside of a function. For example, in the Perl snippet at right,
530:
Scope is a source-code level concept, and a property of name bindings, particularly variable or function name bindings—names in the source code are
412:
at runtime, though whether the actual name binding is done at compile time or run time depends on the language. De facto dynamic scope is common in
601:
is occurring, where the higher-priority name (usually innermost) is "masking" the lower-priority name. At the level of variables, this is known as
2970:
accessible throughout a program, they generally all need names with global scope, so different techniques are required to avoid name collisions.
3966:
has lexical scope for ordinary variables. It also has dynamic variables, but they are in all cases explicitly marked; they must be defined by a
5842:
If the variable to be bound has been declared to be special, the binding is compiled as code to imitate the way the interpreter binds variables
3674:—the declaration, but not the initialization, is hoisted to the top of the function. Thirdly, accessing variables before initialization yields 2114:
So, what exactly does this program print? It depends on the scope rules. If the language of this program is one that uses lexical scope, then
3898:
Name resolution of properties of JavaScript objects is based on inheritance in the prototype tree—a path to the root in the tree is called a
1653:
in the calling function would remain in context in the called function—the scopes would overlap—and would be masked ("shadowed") by the new
5494:
Steele, Guy Lewis Jr.; Sussman, Gerald Jay (May 1978). "The Art of the Interpreter; or, The Modularity Complex (Parts Zero, One and Two)".
2198:
by the language implementation. Because this matching only requires analysis of the static program text, this type of scope is also called
1028:
A representative example of the use of block scope is the C code shown here, where two variables are scoped to the loop: the loop variable
534:
to entities in the program—and is part of the behavior of a compiler or interpreter of a language. As such, issues of scope are similar to
161:
of an entity, particularly in older or more technical literature—this is in relation to the referenced entity, not the referencing name.
2591: 2655:
in any context always yields the top binding. Note that this cannot be done at compile-time because the binding stack only exists at
1297:
to avoid a block, but this is not in general possible for multiple variable assignments, and is difficult to read for complex logic.
617: 453: 433: 100: 53: 72: 373:
can be confusing to the uninitiated, as these depend on the lexical context where the closure is defined, not where it is called.
3633: 2983:(without the prefix) is visible as well. And normally these groups can themselves be organized into groups; that is, they can be 573: 449: 168:
name bindings that are valid within a part of a program or at a given point in a program, which is more correctly referred to as
6052: 2552:, a short review of the history and the divergent implementations of Lisp up to that moment and a review of the features that a 6102: 2615:
The term "lexical scope" dates at least to 1967, while the term "lexical scoping" dates at least to 1970, where it was used in
79: 6074: 5737: 3002:, that serve almost exclusively to enable global names to be organized into groups. Other languages have mechanisms, such as 2194:, a name always refers to its lexical context. This is a property of the program text and is made independent of the runtime 1070:
Block scope can be used for shadowing. In this example, inside the block the auxiliary variable could also have been called
523:). Execution context consists of lexical context (at the current execution point) plus additional runtime state such as the 3026:'s packages are largely similar to C++'s namespaces, but optionally double as classes for object-oriented programming; and 3022:
have a mechanism for which this is the primary purpose). Furthermore, languages often meld these approaches; for example,
2753:
the dynamic scope is restricted to the argument stack of the current function only, and coincides with the lexical scope.
616:
have various different scope rules for different kinds of declarations and names. Such scope rules have a large effect on
5363: 4929:
Variables created or modified within a function stay there unless assignment to enclosing scope is explicitly requested:
862:, where "very declaration ... is valid only for that block.", and today is particularly associated with languages in the 212: 5664:"Controlling Access to Members of a Class (The Java Tutorials > Learning the Java Language > Classes and Objects)" 3938:
treated lexical binding more as an optimization than one would expect in modern languages, and it did not come with the
86: 5388: 2656: 2538: 2534: 506: 385: 307: 3632:
6. Block scope can be produced by wrapping the entire block in a function and then executing it; this is known as the
1067:, which have an initialization statement separate from the loop condition, unlike while loops, and is a common idiom. 609:
from masking, some languages disallow or discourage masking, raising an error or warning at compile time or run time.
569:
is only in context within a function or other local context, but both have lifetime of the entire run of the program.
6043: 5455: 831:
In Python, auxiliary variables in generator expressions and list comprehensions (in Python 3) have expression scope.
192: 119: 5412: 68: 2809:, expanding the macro during the tokenization stage, but not parsing into a syntax tree or doing name resolution. 2674:
bindings will apply when a variable is used (or if one exists at all). This can be beneficial; application of the
2990:
Although many languages support this concept, the details vary greatly. Some languages have mechanisms, such as
554: 481: 3939: 3113: 3054: 2999: 2589:
was published (1982), initial designs (also by Guy L. Steele Jr.) of a compiled, lexically scoped Lisp, called
2223: 1678: 535: 240: 57: 5811: 1389:
When the scope of variables declared within a function does not extend beyond that function, this is known as
5583: 5196:, while "binding" associates the name with an actual meaning. In practice the terms are used interchangeably. 3953: 3917: 3030:
organizes its variables and functions into classes, but then organizes those classes into Ada-like packages.
2548:
used dynamic scope, when based on interpreters. In 1982, Guy L. Steele Jr. and the Common LISP Group publish
2493: 2207: 863: 692: 409: 17: 542:, as it is undefined. However, as variables are not destroyed until they go out of context, the analog of a 5560: 5193: 3624: 3339: 2675: 1750: 1718:
family of languages, and Python (which was influenced by Modula) is a representative contemporary example.
1044:
would generally not be assigned to an auxiliary variable, and the body of the loop would simply be written
531: 276:
An identifier can denote an object; a function; a tag or a member of a structure, union, or enumeration; a
5639:"Declaring Member Variables (The Java Tutorials > Learning the Java Language > Classes and Objects)" 5688: 5663: 3910: 3467: 3328: 3027: 2692: 2545: 2522: 1722: 858:. Block scope is available in many, but not all, block-structured programming languages. This began with 595:
When two identical names are in context at the same time, referring to different entities, one says that
581: 401: 3985:, still use dynamic scope by default. Emacs Lisp now has lexical scope available on a per-buffer basis. 3757: 3007: 2620: 2454: 2215: 1662: 370: 338:), which is defined by where the named variable or function is defined. In contrast, in languages with 4085:
Here assignment creates a new local variable, which does not change the value of the global variable:
1032:, which is initialized once and incremented on each iteration of the loop, and the auxiliary variable 5775: 5638: 4074:
is called, so no error is raised, even though it is defined after its reference in the definition of
3456: 2364:
For example, Pascal is lexically scoped. Consider the Pascal program fragment at right. The variable
2219: 291: 5924: 5425: 2801:
to the passed variable, with this name only later resolved by the compiler based on where the macro
1710:
where modules (which may span various files) are the basic unit of a complex program, as they allow
93: 4723: 4719: 2750: 2611:
read it were taking a bit of a leap of faith that this was going to work in serious production use.
2497: 2227: 867: 413: 311: 270: 5895: 2635:, a name refers to execution context. In technical terms, this means that each name has a global 5180: 5176: 1140:
In Perl, which has block scope, this instead requires declaring the variable prior to the block:
1089:. For example, in Python, which does not use block scope, one may initialize a variable as such: 789: 220: 46: 5996: 2636: 2368:
is visible at all points, because it is never hidden by another variable of the same name. The
1630:; these variables, because of their limited scope, will not interfere with any variables named 1412: 700: 562: 369:. Perl 5 offers both lexical and dynamic scope. Even in lexically scoped languages, scope for 303: 203:. Both of these terms are somewhat misleading—they misuse technical terms, as discussed in the 145: 5588: 5565: 2708: 2529:, which approximates static (lexical) scope, was introduced around 1962 in LISP 1.5 (via the 2458: 1408: 566: 196: 6086:
Section 13.4.1: Scripting Languages: Innovative Features: Names and Scopes, pp. 691–699
5247: 4327:—since it does not assign to the variable, it defaults to resolving to the global variable. 3097:, particularly for variables. C is a lexically scoped language with global scope (known as 2743: 2447: 613: 180: 133: 2500:
have always had lexical scope, since they are both influenced by the ideas that went into
1393:. Function scope is available in most programming languages which offer a way to create a 8: 5206: 2670: 2469: 1707: 851: 653: 469: 228: 2816:
in the macro is resolved (after expansion) to the local variable at the expansion site:
322:
A fundamental distinction in scope is what "part of a program" means. In languages with
6025: 5461: 5345: 3132: 3128: 3089: 3082: 2712: 1711: 1444: 1440: 1418:
Importantly, in lexical scope a variable with function scope has scope only within the
1404: 835: 625: 624:, accessing an unbound variable does not have well-defined semantics and may result in 602: 236: 2735:) ordering to bindings for any one variable; in practice all bindings are so ordered. 6070: 6039: 5451: 5270: 4079: 3670: 2704: 2167: 1086: 671: 366: 232: 5855: 5465: 1562:
For example, in the snippet of Python code on the right, two functions are defined:
310:
has effect—but can also apply to other entities, such as functions, types, classes,
6060: 5825: 5540: 5443: 5335: 4731:) which can simulate the experience of dynamic scope should the programmer desire. 2806: 2732: 2720: 1745: 1727: 1294: 1040:
has accidentally already been set to another value. In this example the expression
629: 543: 405: 149: 6064: 5984:
Emacs 24 has optional lexical binding, which can be enabled on a per-buffer basis.
5604: 5602: 5440:
Proceedings of the 1982 ACM symposium on LISP and functional programming - LFP '82
5349: 3648:
and the variable is assigned its value when the assignment expression is reached:
679:
are usable throughout the function because they are implicitly bound to the value
669:
begins at the start of the function where the name is declared, which is known as
620:
and, consequently, on the behavior and correctness of programs. In languages like
5968: 3942:
feature one might expect of lexical scope in modern Lisps. A separate operation,
3342:
has a similar rule for scopes with C++, but contains different access modifiers.
2784: 2768: 2762: 2566: 2509: 2450: 1436: 1423:
which they are declared. By contrast, in dynamic scope, the scope extends to the
558: 550: 5894:
Pitman, Kent; et al. (webbed version of ANSI standard X3.226-1994) (1996).
5238:"Report on the Algorithmic Language Algol 60", 2.7. Quantities, kinds and scopes 6021: 5879: 5599: 3117: 2780: 2578: 1638:
that might belong to any other function. In other words, there is no risk of a
1395: 705: 154: 1415:, but is only in context within a function, like an automatic local variable. 6096: 5944:
Dynamic bindings are established and accessed by a separate mechanism (i.e.,
5426:
A Symbol Table Abstraction to Implement Languages with Explicit Scope Control
3644:
keyword; the variable is then created at the top of the function, with value
3615: 3109: 343: 5381: 2485:
Lexical scope was first used in the early 1960s for the imperative language
5798: 5779: 5593: 5570: 2772: 2648: 2474: 633: 597: 592:
keywords in Python; in other cases the default rules cannot be overridden.
577: 539: 472:, so a change in one part of the program does not break an unrelated part. 437: 428: 420: 377: 224: 141: 5692: 5447: 5340: 5323: 5302: 5023:
Although R has lexical scope by default, function scopes can be changed:
4005:
As a simple example, a function resolves a variable to the global scope:
3949: 3124: 3015: 2805:
is "called" (properly, expanded). Properly, the C preprocessor only does
2688: 2616: 1694:
to the function signature would result in file scope (internal linkage).
1642:
between these names and any unrelated names, even if they are identical.
1590:
is 0 + 1 + 2 + 3 + 4 = 
710: 606: 416:, which do not directly do name resolution, but instead expand in place. 191:. In some languages, however, "part of a program" refers to a portion of 184: 3042: 2727:
is an alternative strategy that is considerably faster, making use of a
5545: 5510: 3982: 3629: 3603: 2696: 2195: 1758: 1400: 524: 465: 424: 302:
Most commonly "scope" refers to when a given name can refer to a given
252: 2489:
and has been picked up in most other imperative languages since then.
1373:
by one, and return the new value. Code outside of this block can call
1293:
In case of a single variable assignment, an alternative is to use the
665:
begins at the name declaration, and the scope of a name declared with
330:), name resolution depends on the location in the source code and the 6035: 3946:, was available to somewhat clumsily work around some of that issue. 2518:
is a language with dynamic scope that added static scope afterwards.
2443:
it represents, thus precisely analogous with the scope of variables.
2179: 2082:(hiding the identically named global variable) and initializes it to 1754: 216: 5856:"The Revised Maclisp Manual (The Pitmanual), Sunday Morning Edition" 5826:"The Revised Maclisp Manual (The Pitmanual), Sunday Morning Edition" 5321: 4574:
declaration, for assigning to a nonlocal variable, similar to using
1739:
The scope of a name binding is an entire program, which is known as
1714:
and exposing a limited interface. Module scope was pioneered in the
285:(i.e., can be used) only within a region of program text called its 35: 5832:. HyperMeta Inc. Declarations and the Compiler, Concept "Variables" 2505: 2501: 2486: 2211: 1064: 1056: 859: 632:; and declarations or names used outside their scope will generate 256: 3902:—and is separate from name resolution of variables and functions. 5784: 3957: 3935: 3927: 2439:" is mentioned then determines which of the two procedures named 1966:
Consider, for example, the program on the right. The first line,
1048:
but in more complicated examples auxiliary variables are useful.
277: 4722:
is a lexically scoped language, unlike other implementations of
3108:
The lifetime and visibility of a variable are determined by its
2647:
stack (which may have been empty), which is popped off when the
2376:
is visible only in the main program because it is hidden by the
384:, while dynamic resolution can in general only be determined at 5762: 5712: 5438:
Louis Steele, Guy (August 1982). "An overview of COMMON LISP".
3963: 3778:// return a counter that is incremented on call (starting at 0) 2530: 2462: 1715: 5573:, University of Michigan. Engineering Summer Conferences, 1967 5266: 2581:" is completely solved, in both the downward and upward cases. 1578:
computes the sum of all squares up to a number. (For example,
1443:
for the nested function. Function scope is also applicable to
699:. Expression scope is available in many languages, especially 27:
Part of a computer program where a given name binding is valid
5479:
Joel, Moses (June 1970). "The Function of FUNCTION in LISP".
4299:
The default name resolution rules can be overridden with the
3924:, that introduced static (lexical) scope to the Lisp family. 3921: 2995: 2700: 2203: 621: 4835:
Variables created or modified within a function stay there:
3127:, which are then linked into an executable or library via a 5697: 5689:
Everything you need to know about Javascript variable scope
5539:(Technical report). Massachusetts Institute of Technology. 3023: 2684: 2515: 1702:
The scope of a name binding is a module, which is known as
1357:
is a variable name with block scope (due to the use of the
1059:
and C (demonstrated in this example and standardized since
749: 5303:"Code Conventions for the JavaScript Programming Language" 2565:
Implementations of Common LISP were thus required to have
2446:
Correct implementation of lexical scope in languages with
2182:
which uses lexical scope, the results would be different.)
251:
The strict definition of the (lexical) "scope" of a name (
5251: 3116:
level, namely a source file after being processed by the
2138:. By contrast, if this language uses dynamic scope, then 1673:
The scope of a name binding is a file, which is known as
1060: 6083:
Chapter 3: Names, Scopes, and Bindings, pp. 111–174
5925:"Programming Language ISLISP, ISLISP Working Draft 23.0" 2776:(loosely "called"), as if dynamic scope were occurring. 1601:
that represents the argument to the function. These two
346:
when the name is encountered which is determined by the
4294:
local variable 'x' referenced before assignment
2468:
become slightly inefficient when very deeply lexically
2424:
and can therefore not be called from the main program.
486:
When discussing scope, there are three basic concepts:
5209:
the lexical context itself can change during run time.
1645:
No name masking is occurring: only one variable named
572:
Determining which entity a name refers to is known as
6020: 5765:", Annotated ECMAScript 5.1, Last updated: 2012-05-28 5382:"N4720: Working Draft, Extensions to C++ for Modules" 4780:
Functions have access to scope they were created in:
1055:
A subtlety of several programming languages, such as
549:
For entities such as variables, scope is a subset of
164:
The term "scope" is also used to refer to the set of
3754:, by analogy with the prototype chain of an object. 2742:
Dynamic scope provides an excellent abstraction for
2639:
of bindings. Introducing a local variable with name
1764: 1381:. This idiom allows one to define closures in Perl. 1377:, but cannot otherwise obtain or alter the value of 2412:and therefore not accessible either from procedure 1365:is a function name with global scope. Each call to 215:one can maintain a list of names and contexts when 60:. Unsourced material may be challenged and removed. 5254:standard), 6.2.1 Scopes of identifiers, 2007-09-07 3101:), a form of module scope or file scope (known as 2556:implementation should have. On page 102, we read: 2404:but it does not hide any other variable. Variable 2218:as well as in modern functional languages such as 2170:, which uses dynamic scope; so the program prints 2039:(overwriting the previous value). The third line, 317: 144:(an association of a name to an entity, such as a 6031:Structure and Interpretation of Computer Programs 3073:Scope rules for representative languages follow. 2166:. (As it happens, the language of the program is 259:. Representative language specifications follow: 6094: 3934:declarations for particular variables. However, 2619:to describe the scope rules of the Lisp dialect 2027:that prints out ("echoes") the current value of 1688:has global scope (in C, extern linkage). Adding 838:have expression scope, known in this context as 4307:(in Python 3) keywords. In the below code, the 2666:Dynamic scope is uncommon in modern languages. 1684:In the C code snippet above, the function name 1078:would result in a syntax error, and one of the 6069:(Third ed.). Morgan Kaufmann Publishers. 3664:is executed, not when the variable is created. 657:JavaScript, the scope of a name declared with 565:is in context for the entire program, while a 482:Variable (programming) § Scope and extent 5862:. HyperMeta Inc. The Evaluator, Special Form 5493: 5324:"Report on the algorithmic language ALGOL 60" 5294: 3916:The original Lisp used dynamic scope; it was 3473:A Java class has several kinds of variables: 2812:For example, in the following code, the name 2431:declared in the program outside of procedure 1597:Each of these functions has a variable named 235:, while considerably subtler ones arise with 183:, "part of a program" refers to a portion of 5882:," however it only works in some easy cases. 5437: 2659:, which is why this type of scope is called 3120:, notably including all relevant includes. 179:Strictly speaking and in practice for most 3974:special form, and accessed by an explicit 2678:suggests that code avoid depending on the 1743:. Variable names with global scope—called 5566:Computer and Program Organization, Part 3 5544: 5339: 5283: 5281: 5279: 5267:The Go Programming Language Specification 5232: 5158:"Dynamic scope" bases name resolution on 1817:'s local variables (assuming the text of 120:Learn how and when to remove this message 5812:Explaining JavaScript Scope And Closures 5149:for meaning of "scope" versus "context". 4570:For nested functions, there is also the 2427:There could have been another procedure 2118:prints and modifies the global variable 376:Lexical resolution can be determined at 3913:dialects have various rules for scope. 3634:immediately-invoked function expression 2525:interpreter (1960) used dynamic scope. 1825:), while under dynamic scope, function 703:languages which offer a feature called 14: 6095: 5893: 5853: 5823: 5534: 5289:CSE 341 -- Lexical and Dynamic Scoping 5276: 3087:In C, scope is traditionally known as 2508:(although C did not include lexically 1801:invokes a separately defined function 1435:. In languages with lexical scope and 6059: 5608: 5589:Project MAC Progress Report, Volume 8 5300: 3501:are variables in method declarations. 2416:or the main program. Also, procedure 1805:, then under lexical scope, function 342:the name resolution depends upon the 5478: 5262: 5260: 3123:C programs are compiled as separate 3037: 1840:is invoked during the invocation of 1757:. In these cases mechanisms such as 1082:variables would have to be renamed. 58:adding citations to reliable sources 29: 5508: 2457:). Depending on implementation and 2202:. Lexical scope is standard in all 739:, using a temporary variable named 735:is an expression that evaluates to 686: 448:Scope is an important component of 395: 24: 5961: 5854:Pitman, Kent (December 16, 2007). 5824:Pitman, Kent (December 16, 2007). 5535:Steele, Guy Lewis Jr. (May 1978). 5498:. MIT Artificial Intelligence Lab. 5483:. MIT Artificial Intelligence Lab. 5166:, and thus is formally inaccurate. 4263:Traceback (most recent call last): 3981:Some other dialects of Lisp, like 3781:// and which returns its new value 3459:is lexically scoped using blocks. 2964: 2756: 2435:. The place in the program where " 2396:is also visible only in procedure 2107:, prints out the current value of 691:The scope of a name binding is an 642: 452:, which is in turn fundamental to 25: 6114: 5611:, 3.4 Implementing Scope, p. 143. 5257: 2643:pushes a binding onto the global 1574:computes the square of a number; 1427:of the function: local variables 1384: 850:The scope of a name binding is a 419:Some programming frameworks like 223:a program. Difficulties arise in 5814:", Robert Nyman, October 9, 2008 3041: 2626: 2185: 2178:. If the same code was run with 1765:Lexical scope vs. dynamic scope 187:(area of text), and is known as 34: 6066:Programming Language Pragmatics 5989: 5917: 5887: 5878:is intended to help solve the " 5847: 5817: 5804: 5792: 5776:JavaScript Scoping and Hoisting 5768: 5755: 5730: 5705: 5681: 5656: 5631: 5614: 5576: 5553: 5528: 5502: 5487: 5472: 5431: 5418: 5413:Programming Language Pragmatics 5405: 5394:from the original on 2019-04-30 5374: 5356: 5315: 5212: 5199: 5146: 3315:statement have function scope. 1734: 1706:. Module scope is available in 1697: 318:Lexical scope vs. dynamic scope 314:, constants, and enumerations. 204: 45:needs additional citations for 5902:. LispWorks Ltd. 1.1.2 History 5801:, Richard Cornford. March 2004 5241: 5186: 5169: 5152: 5139: 4082:, which is allowed in Python. 3033: 2078:that creates a local variable 1761:are used to avoid collisions. 845: 13: 1: 6103:Programming language concepts 5537:RABBIT: A Compiler for SCHEME 5250:(2007 updated version of the 5225: 3656:is assigned the value of its 3598: 2651:leaves the scope. Evaluating 2420:is visible only in procedure 2408:is only visible in procedure 1708:modular programming languages 1668: 1241:while in Perl this would be: 468:, scope rules are crucial in 246: 69:"Scope" computer science 5934:. 11.1 The lexical principle 5415:", LeBlank-Cook symbol table 5364:"Functions - Javascript:MDN" 5194:higher-order abstract syntax 2676:principle of least knowledge 1978:, creates a global variable 1661:enclosing context) create a 628:, similar to referring to a 7: 5291:. University of Washington. 3952:adopted lexical scope from 3628:keywords is standard since 1723:object-oriented programming 1369:will increase the value of 605:. Due to the potential for 582:object-oriented programming 475: 402:object-oriented programming 10: 6119: 6028:; Sussman, Julie (1996) . 3889:// outputs "1 2" 3080: 2760: 2623:(then known as "Muddle"). 2587:An overview of Common LISP 2585:By the same year in which 2571:An overview of Common LISP 2550:An overview of Common LISP 2480: 1958:# does this print 1, or 2? 1943:# does this print 1, or 3? 1836:'s local variables (since 1821:is not inside the text of 1618:being altered. Similarly, 834:In C, variable names in a 479: 5328:Communications of the ACM 5273:, Version of Nov 13, 2013 4734:There is no block scope: 4578:in an unnested function: 4323:declaration is needed in 4279:"<stdin>" 4267:"<stdin>" 3988: 3970:special form, bound by a 3357:Containing module/package 2226:. It is also used in the 2206:-based languages such as 2158:), so the program prints 2130:), so the program prints 2099: 2091: 2040: 1987: 1967: 1689: 793: 753: 5626:XL C/C++ V8.0 for Linux, 5132: 5025: 4931: 4837: 4782: 4736: 4580: 4469: 4329: 4197: 4087: 4007: 3763: 3684: 3618:). Block scope with the 3394:Yes, disallows subclass 3334: 3144: 3135:for further discussion. 2818: 2789: 2751:referential transparency 2703:and the shell languages 2233: 1846: 1657:in the called function. 1449: 1433:and all called functions 1303: 1243: 1209: 1142: 1133:is accessible after the 1091: 873: 5896:"Common Lisp HyperSpec" 5763:12.2 Variable Statement 5181:Import Context Behavior 3905: 3462: 2729:central reference table 2599:, Olin Shivers writes: 840:function protocol scope 388:, and thus is known as 380:, and is also known as 5271:Declarations and scope 4078:. Lexically this is a 3331:nested lexical scope. 3318: 2821:#define ADD_A(x) x + a 2792:#define ADD_A(x) x + a 2613: 2583: 2563: 2154:is called from within 1982:and initializes it to 1413:static global variable 1409:static local variables 563:static global variable 443: 5448:10.1145/800068.802140 5428:", LeBlank-Cook, 1983 5341:10.1145/367236.367262 3470:is lexically scoped. 3451: 3377:Yes, allows subclass 3308:The program outputs: 2767:In modern languages, 2601: 2575: 2558: 2459:computer architecture 2384:visible in procedure 2023:, defines a function 1770:"within" a function? 614:programming languages 567:static local variable 181:programming languages 6053:"Lexical addressing" 5301:Crockford, Douglas. 4714: 3658:AssignmentExpression 3076: 2744:thread-local storage 2533:device developed by 2142:prints and modifies 1622:has variables named 854:, which is known as 695:, which is known as 229:forward declarations 134:computer programming 54:improve this article 6026:Sussman, Gerald Jay 5799:Javascript Closures 5442:. pp. 98–107. 5207:self-modifying code 3652:A variable with an 2797:will expand to add 2669:Generally, certain 2126:is defined outside 2090:. The fourth line, 2074:defines a function 1986:. The second line, 1753:and names of other 1445:anonymous functions 654:forward declaration 470:modular programming 237:non-local variables 199:), and is known as 148:) is the part of a 6001:cran.r-project.org 4679:"global" 4553:"global" 4422:"global" 4251:"global" 4141:"global" 4070:is defined before 4049:"global" 3360:Rest of the world 3083:Linkage (software) 3053:. You can help by 2146:'s local variable 2098:. The fifth line, 1712:information hiding 1441:non-local variable 1405:automatic variable 836:function prototype 626:undefined behavior 618:language semantics 603:variable shadowing 511:execution context, 505:) or a portion of 454:language semantics 408:selects an object 367:template languages 239:, particularly in 6076:978-0-12-374514-9 6061:Scott, Michael L. 6034:. Cambridge, MA: 5969:"Lexical Binding" 5366:. 23 April 2023. 5175:For example, the 4290:UnboundLocalError 4080:forward reference 3671:variable hoisting 3668:This is known as 3662:VariableStatement 3596: 3595: 3449: 3448: 3071: 3070: 2086:, and then calls 1588:sum_of_squares(4) 1582:is 4 =  1425:execution context 1399:in a function or 1375:increment_counter 1367:increment_counter 1363:increment_counter 1327:increment_counter 1087:single assignment 743:to avoid calling 672:variable hoisting 580:(particularly in 464:). Together with 348:execution context 130: 129: 122: 104: 16:(Redirected from 6110: 6080: 6049: 6012: 6011: 6009: 6007: 5993: 5987: 5986: 5981: 5979: 5965: 5959: 5958: 5955: 5951: 5947: 5941: 5939: 5929: 5921: 5915: 5914: 5909: 5907: 5891: 5885: 5884: 5877: 5872: 5870: 5865: 5851: 5845: 5844: 5839: 5837: 5821: 5815: 5808: 5802: 5796: 5790: 5772: 5766: 5759: 5753: 5752: 5750: 5748: 5734: 5728: 5727: 5725: 5723: 5709: 5703: 5685: 5679: 5678: 5676: 5674: 5660: 5654: 5653: 5651: 5649: 5635: 5629: 5618: 5612: 5606: 5597: 5580: 5574: 5557: 5551: 5550: 5548: 5532: 5526: 5525: 5523: 5521: 5506: 5500: 5499: 5491: 5485: 5484: 5476: 5470: 5469: 5435: 5429: 5422: 5416: 5409: 5403: 5402: 5400: 5399: 5393: 5386: 5378: 5372: 5371: 5360: 5354: 5353: 5343: 5319: 5313: 5312: 5310: 5309: 5298: 5292: 5285: 5274: 5264: 5255: 5245: 5239: 5236: 5219: 5216: 5210: 5203: 5197: 5190: 5184: 5173: 5167: 5162:(lifetime), not 5156: 5150: 5143: 5128: 5125: 5122: 5119: 5116: 5113: 5110: 5107: 5104: 5101: 5098: 5095: 5092: 5089: 5086: 5083: 5080: 5077: 5074: 5071: 5068: 5065: 5062: 5059: 5056: 5053: 5050: 5047: 5044: 5041: 5038: 5035: 5032: 5029: 5019: 5016: 5013: 5010: 5007: 5004: 5001: 4998: 4995: 4992: 4989: 4986: 4983: 4980: 4977: 4974: 4971: 4968: 4965: 4962: 4959: 4956: 4953: 4950: 4947: 4944: 4941: 4938: 4935: 4925: 4922: 4919: 4916: 4913: 4910: 4907: 4904: 4901: 4898: 4895: 4892: 4889: 4886: 4883: 4880: 4877: 4874: 4871: 4868: 4865: 4862: 4859: 4856: 4853: 4850: 4847: 4844: 4841: 4831: 4828: 4825: 4822: 4819: 4816: 4813: 4810: 4807: 4804: 4801: 4798: 4795: 4792: 4789: 4786: 4776: 4773: 4770: 4767: 4764: 4761: 4758: 4755: 4752: 4749: 4746: 4743: 4740: 4730: 4710: 4707: 4704: 4701: 4698: 4695: 4692: 4689: 4686: 4683: 4680: 4677: 4674: 4671: 4668: 4665: 4662: 4659: 4656: 4653: 4650: 4647: 4644: 4641: 4638: 4635: 4632: 4629: 4626: 4623: 4620: 4617: 4614: 4611: 4608: 4605: 4602: 4599: 4596: 4593: 4590: 4587: 4584: 4577: 4573: 4566: 4563: 4560: 4557: 4554: 4551: 4548: 4545: 4542: 4539: 4536: 4533: 4530: 4527: 4524: 4521: 4518: 4515: 4512: 4509: 4506: 4503: 4500: 4497: 4494: 4491: 4488: 4485: 4482: 4479: 4476: 4473: 4465: 4459: 4456: 4453: 4450: 4447: 4444: 4441: 4438: 4435: 4432: 4429: 4426: 4423: 4420: 4417: 4414: 4411: 4408: 4405: 4402: 4399: 4396: 4393: 4390: 4387: 4384: 4381: 4378: 4375: 4372: 4369: 4366: 4363: 4360: 4357: 4354: 4351: 4348: 4345: 4342: 4339: 4336: 4333: 4326: 4322: 4318: 4314: 4310: 4306: 4302: 4295: 4291: 4288: 4284: 4280: 4276: 4272: 4268: 4264: 4261: 4258: 4255: 4252: 4249: 4246: 4243: 4240: 4237: 4234: 4231: 4228: 4225: 4222: 4219: 4216: 4213: 4210: 4207: 4204: 4201: 4190: 4187: 4184: 4181: 4178: 4175: 4172: 4169: 4166: 4163: 4160: 4157: 4154: 4151: 4148: 4145: 4142: 4139: 4136: 4133: 4130: 4127: 4124: 4121: 4118: 4115: 4112: 4109: 4106: 4103: 4100: 4097: 4094: 4091: 4077: 4073: 4069: 4062: 4059: 4056: 4053: 4050: 4047: 4044: 4041: 4038: 4035: 4032: 4029: 4026: 4023: 4020: 4017: 4014: 4011: 4001: 3997: 3977: 3973: 3969: 3945: 3933: 3890: 3887: 3884: 3881: 3878: 3875: 3872: 3869: 3866: 3863: 3860: 3857: 3854: 3851: 3848: 3845: 3842: 3839: 3836: 3833: 3830: 3827: 3824: 3821: 3818: 3815: 3812: 3809: 3806: 3803: 3800: 3797: 3794: 3791: 3788: 3785: 3782: 3779: 3776: 3773: 3770: 3767: 3745: 3742: 3739: 3736: 3733: 3730: 3727: 3724: 3721: 3718: 3715: 3712: 3709: 3706: 3703: 3700: 3697: 3694: 3691: 3688: 3681: 3677: 3647: 3643: 3636:(IIFE) pattern. 3627: 3621: 3509: 3508: 3486:Member variables 3345: 3344: 3327:Modern versions 3304: 3301: 3298: 3295: 3292: 3289: 3286: 3283: 3280: 3277: 3274: 3271: 3268: 3265: 3262: 3259: 3256: 3253: 3250: 3247: 3244: 3241: 3238: 3235: 3232: 3229: 3226: 3223: 3220: 3217: 3214: 3211: 3208: 3205: 3202: 3199: 3196: 3193: 3190: 3187: 3184: 3181: 3178: 3175: 3172: 3169: 3166: 3163: 3160: 3157: 3154: 3151: 3148: 3114:translation unit 3103:internal linkage 3099:external linkage 3066: 3063: 3045: 3038: 2981:unqualified name 2960: 2957: 2954: 2951: 2948: 2945: 2942: 2939: 2936: 2933: 2930: 2927: 2924: 2921: 2918: 2915: 2912: 2909: 2906: 2903: 2900: 2897: 2894: 2891: 2888: 2885: 2882: 2879: 2876: 2873: 2870: 2867: 2864: 2861: 2858: 2855: 2852: 2849: 2846: 2843: 2840: 2837: 2834: 2831: 2828: 2825: 2822: 2815: 2807:lexical analysis 2804: 2800: 2793: 2721:association list 2654: 2646: 2642: 2537:, working under 2510:nested functions 2451:nested functions 2442: 2438: 2434: 2430: 2423: 2419: 2415: 2411: 2407: 2403: 2399: 2395: 2391: 2387: 2383: 2379: 2375: 2371: 2367: 2360: 2357: 2354: 2351: 2348: 2345: 2342: 2339: 2336: 2333: 2330: 2327: 2324: 2321: 2318: 2315: 2312: 2309: 2306: 2303: 2300: 2297: 2294: 2291: 2288: 2285: 2282: 2279: 2276: 2273: 2270: 2267: 2264: 2261: 2258: 2255: 2252: 2249: 2246: 2243: 2240: 2237: 2177: 2173: 2165: 2161: 2157: 2153: 2149: 2145: 2141: 2137: 2133: 2129: 2125: 2121: 2117: 2110: 2106: 2105: 2102: 2097: 2093: 2089: 2085: 2081: 2077: 2073: 2072: 2069: 2065: 2062: 2059: 2056: 2053: 2050: 2047: 2043: 2038: 2034: 2031:, and then sets 2030: 2026: 2022: 2021: 2018: 2015: 2012: 2009: 2006: 2003: 2000: 1997: 1994: 1990: 1985: 1981: 1977: 1976: 1973: 1970: 1962: 1959: 1956: 1953: 1950: 1947: 1944: 1940: 1937: 1934: 1930: 1927: 1924: 1921: 1918: 1915: 1912: 1908: 1905: 1902: 1899: 1896: 1893: 1890: 1887: 1884: 1881: 1878: 1875: 1871: 1868: 1865: 1862: 1859: 1856: 1853: 1850: 1843: 1839: 1835: 1828: 1824: 1820: 1816: 1808: 1804: 1800: 1746:global variables 1728:dynamic dispatch 1693: 1692: 1687: 1679:translation unit 1621: 1614:without its own 1613: 1609: 1593: 1589: 1585: 1581: 1577: 1573: 1569: 1565: 1558: 1555: 1552: 1549: 1546: 1543: 1540: 1537: 1534: 1531: 1528: 1525: 1522: 1519: 1516: 1513: 1510: 1507: 1504: 1501: 1498: 1495: 1492: 1489: 1486: 1483: 1480: 1477: 1474: 1471: 1468: 1465: 1462: 1459: 1456: 1453: 1437:nested functions 1380: 1376: 1372: 1368: 1364: 1361:keyword), while 1360: 1356: 1349: 1346: 1343: 1340: 1337: 1334: 1331: 1328: 1325: 1322: 1319: 1316: 1313: 1310: 1307: 1295:ternary operator 1289: 1286: 1283: 1280: 1277: 1274: 1271: 1268: 1265: 1262: 1259: 1256: 1253: 1250: 1247: 1237: 1234: 1231: 1228: 1225: 1222: 1219: 1216: 1213: 1203: 1200: 1197: 1194: 1191: 1188: 1185: 1182: 1179: 1176: 1173: 1170: 1167: 1164: 1161: 1158: 1155: 1152: 1149: 1146: 1136: 1132: 1125: 1122: 1119: 1116: 1113: 1110: 1107: 1104: 1101: 1098: 1095: 1047: 1043: 1024: 1021: 1018: 1015: 1012: 1009: 1006: 1003: 1000: 997: 994: 991: 988: 985: 982: 979: 976: 973: 970: 967: 964: 961: 958: 955: 952: 949: 946: 943: 940: 937: 934: 931: 928: 925: 922: 919: 916: 913: 910: 907: 904: 901: 898: 895: 892: 889: 886: 883: 880: 877: 827: 826: 823: 820: 817: 814: 811: 808: 805: 802: 799: 796: 787: 786: 783: 780: 777: 774: 771: 768: 765: 762: 759: 756: 746: 742: 738: 734: 720: 716: 697:expression scope 687:Expression scope 682: 678: 668: 664: 660: 630:dangling pointer 591: 587: 559:static variables 546:does not exist. 544:dangling pointer 514:runtime context, 429:AngularJS scopes 406:dynamic dispatch 396:Related concepts 125: 118: 114: 111: 105: 103: 62: 38: 30: 21: 6118: 6117: 6113: 6112: 6111: 6109: 6108: 6107: 6093: 6092: 6091: 6077: 6046: 6022:Abelson, Harold 6016: 6015: 6005: 6003: 5995: 5994: 5990: 5977: 5975: 5967: 5966: 5962: 5953: 5949: 5945: 5937: 5935: 5927: 5923: 5922: 5918: 5905: 5903: 5892: 5888: 5875: 5868: 5866: 5863: 5852: 5848: 5835: 5833: 5822: 5818: 5809: 5805: 5797: 5793: 5785:Adequately Good 5773: 5769: 5760: 5756: 5746: 5744: 5736: 5735: 5731: 5721: 5719: 5713:"Annotated ES5" 5711: 5710: 5706: 5686: 5682: 5672: 5670: 5668:docs.oracle.com 5662: 5661: 5657: 5647: 5645: 5643:docs.oracle.com 5637: 5636: 5632: 5619: 5615: 5607: 5600: 5584:lexical scoping 5581: 5577: 5558: 5554: 5533: 5529: 5519: 5517: 5509:Shivers, Olin. 5507: 5503: 5496:MIT AI Memo 453 5492: 5488: 5481:MIT AI Memo 199 5477: 5473: 5458: 5436: 5432: 5423: 5419: 5410: 5406: 5397: 5395: 5391: 5384: 5380: 5379: 5375: 5362: 5361: 5357: 5320: 5316: 5307: 5305: 5299: 5295: 5286: 5277: 5265: 5258: 5246: 5242: 5237: 5233: 5228: 5223: 5222: 5217: 5213: 5204: 5200: 5191: 5187: 5174: 5170: 5157: 5153: 5144: 5140: 5135: 5130: 5129: 5126: 5123: 5120: 5117: 5114: 5111: 5108: 5105: 5102: 5099: 5096: 5093: 5090: 5087: 5084: 5081: 5078: 5075: 5072: 5069: 5066: 5063: 5060: 5057: 5054: 5051: 5048: 5045: 5042: 5039: 5036: 5033: 5030: 5027: 5021: 5020: 5017: 5014: 5011: 5008: 5005: 5002: 4999: 4996: 4993: 4990: 4987: 4984: 4981: 4978: 4975: 4972: 4969: 4966: 4963: 4960: 4957: 4954: 4951: 4948: 4945: 4942: 4939: 4936: 4933: 4927: 4926: 4923: 4920: 4917: 4914: 4911: 4908: 4905: 4902: 4899: 4896: 4893: 4890: 4887: 4884: 4881: 4878: 4875: 4872: 4869: 4866: 4863: 4860: 4857: 4854: 4851: 4848: 4845: 4842: 4839: 4833: 4832: 4829: 4826: 4823: 4820: 4817: 4814: 4811: 4808: 4805: 4802: 4799: 4796: 4793: 4790: 4787: 4784: 4778: 4777: 4774: 4771: 4768: 4765: 4762: 4759: 4756: 4753: 4750: 4747: 4744: 4741: 4738: 4728: 4717: 4712: 4711: 4708: 4705: 4702: 4699: 4696: 4693: 4690: 4687: 4684: 4681: 4678: 4675: 4672: 4669: 4666: 4663: 4660: 4657: 4654: 4651: 4648: 4645: 4642: 4639: 4636: 4633: 4630: 4627: 4624: 4621: 4618: 4616:# Python 3 only 4615: 4612: 4609: 4606: 4603: 4600: 4597: 4594: 4591: 4588: 4585: 4582: 4575: 4571: 4568: 4567: 4564: 4561: 4558: 4555: 4552: 4549: 4546: 4543: 4540: 4537: 4534: 4531: 4528: 4525: 4522: 4519: 4516: 4513: 4510: 4507: 4504: 4501: 4498: 4495: 4492: 4489: 4486: 4483: 4480: 4477: 4474: 4471: 4463: 4461: 4460: 4457: 4454: 4451: 4448: 4445: 4442: 4439: 4436: 4433: 4430: 4427: 4424: 4421: 4418: 4415: 4412: 4409: 4406: 4403: 4400: 4397: 4394: 4391: 4388: 4385: 4382: 4379: 4376: 4373: 4370: 4367: 4364: 4361: 4358: 4355: 4352: 4349: 4346: 4343: 4340: 4337: 4334: 4331: 4324: 4320: 4316: 4312: 4311:declaration in 4308: 4304: 4300: 4297: 4296: 4293: 4289: 4286: 4282: 4278: 4274: 4270: 4266: 4262: 4259: 4256: 4253: 4250: 4247: 4244: 4241: 4238: 4235: 4232: 4229: 4226: 4223: 4220: 4217: 4214: 4211: 4208: 4205: 4202: 4199: 4192: 4191: 4188: 4185: 4182: 4179: 4176: 4173: 4170: 4167: 4164: 4161: 4158: 4155: 4152: 4149: 4146: 4143: 4140: 4137: 4134: 4131: 4128: 4125: 4122: 4119: 4116: 4113: 4110: 4107: 4104: 4101: 4098: 4095: 4092: 4089: 4075: 4071: 4067: 4064: 4063: 4060: 4057: 4054: 4051: 4048: 4045: 4042: 4039: 4036: 4033: 4030: 4027: 4024: 4021: 4018: 4015: 4012: 4009: 3999: 3995: 3991: 3975: 3971: 3967: 3943: 3931: 3908: 3900:prototype chain 3892: 3891: 3888: 3885: 3882: 3879: 3876: 3873: 3870: 3867: 3864: 3861: 3858: 3855: 3852: 3849: 3846: 3843: 3840: 3837: 3834: 3831: 3828: 3825: 3822: 3819: 3816: 3813: 3810: 3807: 3804: 3801: 3798: 3795: 3792: 3789: 3786: 3783: 3780: 3777: 3774: 3771: 3768: 3765: 3747: 3746: 3743: 3740: 3737: 3734: 3731: 3728: 3725: 3722: 3719: 3716: 3713: 3710: 3707: 3704: 3701: 3698: 3695: 3692: 3689: 3686: 3679: 3675: 3645: 3641: 3623: 3619: 3601: 3477:Local variables 3465: 3454: 3351:Immediate scope 3337: 3321: 3312: 3306: 3305: 3302: 3299: 3296: 3293: 3290: 3287: 3284: 3281: 3278: 3275: 3272: 3269: 3266: 3263: 3260: 3257: 3254: 3251: 3248: 3245: 3242: 3239: 3236: 3233: 3230: 3227: 3224: 3221: 3218: 3215: 3212: 3209: 3206: 3203: 3200: 3197: 3194: 3191: 3188: 3185: 3182: 3179: 3176: 3173: 3170: 3167: 3164: 3161: 3158: 3155: 3152: 3150:<stdio.h> 3149: 3146: 3085: 3079: 3067: 3061: 3058: 3051:needs expansion 3036: 2967: 2965:Qualified names 2962: 2961: 2958: 2955: 2952: 2949: 2946: 2943: 2940: 2937: 2934: 2931: 2928: 2925: 2922: 2919: 2916: 2913: 2910: 2907: 2904: 2901: 2898: 2895: 2892: 2889: 2886: 2883: 2880: 2877: 2874: 2871: 2868: 2865: 2862: 2859: 2856: 2853: 2850: 2847: 2844: 2841: 2838: 2835: 2832: 2829: 2826: 2823: 2820: 2813: 2802: 2798: 2795: 2794: 2791: 2785:macro expansion 2769:macro expansion 2765: 2763:Macro expansion 2759: 2757:Macro expansion 2725:Shallow binding 2652: 2644: 2640: 2629: 2492:Languages like 2483: 2440: 2436: 2432: 2428: 2421: 2417: 2413: 2409: 2405: 2401: 2397: 2393: 2392:only. Variable 2389: 2385: 2381: 2377: 2373: 2369: 2365: 2362: 2361: 2358: 2355: 2352: 2349: 2346: 2343: 2340: 2337: 2335:(*scope A+B+C*) 2334: 2331: 2328: 2325: 2322: 2319: 2316: 2313: 2310: 2307: 2304: 2301: 2298: 2295: 2292: 2289: 2286: 2283: 2280: 2277: 2274: 2271: 2268: 2265: 2262: 2259: 2256: 2253: 2250: 2247: 2244: 2241: 2238: 2235: 2188: 2175: 2171: 2163: 2159: 2155: 2151: 2147: 2143: 2139: 2135: 2131: 2127: 2123: 2119: 2115: 2108: 2103: 2100: 2095: 2087: 2083: 2079: 2075: 2070: 2067: 2063: 2060: 2057: 2054: 2051: 2048: 2045: 2041: 2036: 2032: 2028: 2024: 2019: 2016: 2013: 2010: 2007: 2004: 2001: 1998: 1995: 1992: 1988: 1983: 1979: 1974: 1971: 1968: 1964: 1963: 1960: 1957: 1954: 1951: 1948: 1945: 1942: 1938: 1935: 1932: 1928: 1925: 1922: 1919: 1916: 1913: 1910: 1906: 1903: 1900: 1897: 1894: 1891: 1888: 1885: 1882: 1879: 1876: 1873: 1869: 1866: 1863: 1860: 1857: 1854: 1852:# bash language 1851: 1848: 1841: 1837: 1833: 1832:have access to 1826: 1822: 1818: 1814: 1813:have access to 1806: 1802: 1798: 1795:dynamic scoping 1779:lexical scoping 1767: 1737: 1700: 1690: 1685: 1671: 1656: 1652: 1648: 1637: 1633: 1629: 1625: 1619: 1617: 1611: 1607: 1604: 1600: 1591: 1587: 1583: 1579: 1575: 1571: 1567: 1563: 1560: 1559: 1556: 1553: 1550: 1547: 1544: 1541: 1538: 1535: 1532: 1529: 1526: 1523: 1520: 1517: 1514: 1511: 1508: 1505: 1502: 1499: 1496: 1493: 1490: 1487: 1484: 1481: 1478: 1475: 1472: 1469: 1466: 1463: 1460: 1457: 1454: 1451: 1429:stay in context 1420:lexical context 1387: 1378: 1374: 1370: 1366: 1362: 1358: 1354: 1351: 1350: 1347: 1344: 1341: 1338: 1335: 1332: 1329: 1326: 1323: 1320: 1317: 1314: 1311: 1308: 1305: 1291: 1290: 1287: 1284: 1281: 1278: 1275: 1272: 1269: 1266: 1263: 1260: 1257: 1254: 1251: 1248: 1245: 1239: 1238: 1236:"foo" 1235: 1232: 1229: 1226: 1223: 1220: 1217: 1214: 1211: 1205: 1204: 1201: 1198: 1195: 1192: 1189: 1186: 1183: 1180: 1177: 1174: 1171: 1168: 1165: 1162: 1159: 1156: 1153: 1150: 1147: 1144: 1134: 1130: 1127: 1126: 1123: 1120: 1117: 1114: 1111: 1109:"foo" 1108: 1105: 1102: 1099: 1096: 1093: 1081: 1077: 1073: 1045: 1041: 1039: 1035: 1031: 1026: 1025: 1022: 1019: 1016: 1013: 1010: 1007: 1004: 1001: 998: 995: 992: 989: 986: 983: 980: 977: 974: 971: 968: 965: 962: 959: 956: 953: 950: 947: 944: 941: 938: 935: 932: 929: 926: 923: 920: 917: 914: 911: 908: 905: 902: 899: 896: 893: 890: 887: 884: 881: 878: 875: 848: 824: 821: 818: 815: 812: 809: 806: 803: 800: 797: 794: 784: 781: 778: 775: 772: 769: 766: 763: 760: 757: 754: 744: 740: 736: 722: 718: 714: 706:let expressions 689: 680: 676: 666: 662: 658: 645: 643:Levels of scope 589: 585: 574:name resolution 553:(also known as 521:dynamic context 517:calling context 499:lexical context 484: 478: 450:name resolution 446: 414:macro languages 398: 360:dynamic context 356:calling context 352:runtime context 332:lexical context 320: 263:ALGOL 60 (1960) 249: 195:(period during 155:name collisions 126: 115: 109: 106: 63: 61: 51: 39: 28: 23: 22: 15: 12: 11: 5: 6116: 6106: 6105: 6090: 6089: 6088: 6087: 6084: 6075: 6057: 6056: 6055: 6044: 6017: 6014: 6013: 5988: 5960: 5916: 5886: 5880:funarg problem 5846: 5816: 5803: 5791: 5767: 5754: 5729: 5704: 5698:Coding is Cool 5680: 5655: 5630: 5613: 5598: 5575: 5552: 5527: 5511:"History of T" 5501: 5486: 5471: 5456: 5430: 5417: 5404: 5373: 5355: 5314: 5293: 5275: 5256: 5240: 5230: 5229: 5227: 5224: 5221: 5220: 5211: 5198: 5185: 5168: 5151: 5137: 5136: 5134: 5131: 5026: 4932: 4838: 4783: 4737: 4729:parent.frame() 4716: 4713: 4581: 4470: 4330: 4275:<module> 4198: 4088: 4008: 3990: 3987: 3978:special form. 3920:, inspired by 3907: 3904: 3764: 3685: 3666: 3665: 3600: 3597: 3594: 3593: 3590: 3587: 3584: 3581: 3577: 3576: 3573: 3570: 3567: 3564: 3560: 3559: 3556: 3553: 3550: 3547: 3543: 3542: 3539: 3536: 3533: 3530: 3526: 3525: 3522: 3519: 3516: 3513: 3503: 3502: 3499: 3495: 3494: 3487: 3483: 3482: 3478: 3464: 3461: 3453: 3450: 3447: 3446: 3443: 3440: 3437: 3434: 3430: 3429: 3426: 3423: 3420: 3417: 3413: 3412: 3409: 3406: 3403: 3400: 3396: 3395: 3392: 3389: 3386: 3383: 3379: 3378: 3375: 3372: 3369: 3366: 3362: 3361: 3358: 3355: 3352: 3349: 3336: 3333: 3320: 3317: 3310: 3145: 3118:C preprocessor 3081:Main article: 3078: 3075: 3069: 3068: 3048: 3046: 3035: 3032: 2976:qualified name 2966: 2963: 2819: 2790: 2781:C preprocessor 2761:Main article: 2758: 2755: 2628: 2625: 2597:A History of T 2579:FUNARG problem 2569:. Again, from 2482: 2479: 2234: 2187: 2184: 1847: 1787:static scoping 1781:; also called 1766: 1763: 1736: 1733: 1699: 1696: 1686:sum_of_squares 1670: 1667: 1654: 1650: 1646: 1640:name collision 1635: 1631: 1627: 1623: 1620:sum_of_squares 1615: 1608:sum_of_squares 1602: 1598: 1576:sum_of_squares 1568:sum_of_squares 1482:sum_of_squares 1450: 1396:local variable 1391:function scope 1386: 1385:Function scope 1383: 1304: 1244: 1210: 1143: 1092: 1079: 1075: 1071: 1037: 1033: 1029: 882:sum_of_squares 874: 847: 844: 688: 685: 644: 641: 503:static context 477: 474: 445: 442: 397: 394: 336:static context 319: 316: 300: 299: 295: 289: 274: 268: 264: 248: 245: 213:implementation 128: 127: 42: 40: 33: 26: 9: 6: 4: 3: 2: 6115: 6104: 6101: 6100: 6098: 6085: 6082: 6081: 6078: 6072: 6068: 6067: 6062: 6058: 6054: 6051: 6050: 6047: 6045:0-262-51087-1 6041: 6037: 6033: 6032: 6027: 6023: 6019: 6018: 6002: 5998: 5992: 5985: 5974: 5970: 5964: 5957: 5933: 5926: 5920: 5913: 5901: 5900:Lispworks.com 5897: 5890: 5883: 5881: 5861: 5857: 5850: 5843: 5831: 5827: 5820: 5813: 5807: 5800: 5795: 5788: 5786: 5781: 5777: 5771: 5764: 5758: 5743: 5739: 5733: 5718: 5717:es5.github.io 5714: 5708: 5701: 5699: 5694: 5693:Saurab Parakh 5690: 5684: 5669: 5665: 5659: 5644: 5640: 5634: 5627: 5623: 5617: 5610: 5605: 5603: 5595: 5591: 5590: 5585: 5579: 5572: 5568: 5567: 5562: 5561:lexical scope 5556: 5547: 5542: 5538: 5531: 5516: 5512: 5505: 5497: 5490: 5482: 5475: 5467: 5463: 5459: 5457:0-89791-082-6 5453: 5449: 5445: 5441: 5434: 5427: 5421: 5414: 5408: 5390: 5383: 5377: 5370: 5365: 5359: 5351: 5347: 5342: 5337: 5333: 5329: 5325: 5318: 5304: 5297: 5290: 5284: 5282: 5280: 5272: 5268: 5263: 5261: 5253: 5249: 5244: 5235: 5231: 5215: 5208: 5202: 5195: 5189: 5182: 5178: 5172: 5165: 5161: 5155: 5148: 5142: 5138: 5024: 4930: 4836: 4781: 4735: 4732: 4725: 4721: 4694:>>> 4682:>>> 4670:>>> 4640:"f" 4628:"g" 4583:>>> 4579: 4556:>>> 4544:>>> 4529:"f" 4472:>>> 4468: 4449:>>> 4437:>>> 4425:>>> 4413:>>> 4407:"g" 4362:>>> 4332:>>> 4328: 4254:>>> 4242:>>> 4236:"f" 4200:>>> 4196: 4174:>>> 4162:>>> 4144:>>> 4132:>>> 4111:"f" 4090:>>> 4086: 4083: 4081: 4052:>>> 4040:>>> 4010:>>> 4006: 4003: 3986: 3984: 3979: 3965: 3961: 3959: 3955: 3951: 3947: 3941: 3937: 3929: 3925: 3923: 3919: 3914: 3912: 3903: 3901: 3896: 3762: 3759: 3755: 3753: 3683: 3673: 3672: 3663: 3659: 3655: 3651: 3650: 3649: 3637: 3635: 3631: 3626: 3617: 3616:function type 3611: 3609: 3605: 3591: 3588: 3585: 3582: 3579: 3578: 3574: 3571: 3568: 3565: 3563:(no modifier) 3562: 3561: 3557: 3554: 3551: 3548: 3545: 3544: 3540: 3537: 3534: 3531: 3528: 3527: 3523: 3520: 3517: 3514: 3511: 3510: 3507: 3500: 3497: 3496: 3492: 3488: 3485: 3484: 3479: 3476: 3475: 3474: 3471: 3469: 3460: 3458: 3444: 3441: 3438: 3435: 3432: 3431: 3427: 3424: 3421: 3418: 3415: 3414: 3410: 3407: 3404: 3401: 3398: 3397: 3393: 3390: 3387: 3384: 3381: 3380: 3376: 3373: 3370: 3367: 3364: 3363: 3359: 3356: 3353: 3350: 3347: 3346: 3343: 3341: 3332: 3330: 3325: 3316: 3309: 3143: 3140: 3136: 3134: 3130: 3126: 3121: 3119: 3115: 3111: 3110:storage class 3106: 3104: 3100: 3096: 3092: 3091: 3084: 3074: 3065: 3056: 3052: 3049:This section 3047: 3044: 3040: 3039: 3031: 3029: 3025: 3021: 3017: 3013: 3009: 3005: 3001: 2997: 2993: 2988: 2986: 2982: 2977: 2971: 2817: 2810: 2808: 2788: 2786: 2782: 2777: 2774: 2770: 2764: 2754: 2752: 2747: 2745: 2740: 2736: 2734: 2730: 2726: 2722: 2716: 2714: 2710: 2706: 2702: 2698: 2694: 2690: 2686: 2681: 2677: 2672: 2667: 2664: 2662: 2658: 2650: 2638: 2634: 2633:dynamic scope 2627:Dynamic scope 2624: 2622: 2618: 2612: 2610: 2605: 2600: 2598: 2594: 2593: 2588: 2582: 2580: 2574: 2572: 2568: 2567:lexical scope 2562: 2557: 2555: 2551: 2547: 2542: 2540: 2539:John McCarthy 2536: 2535:Steve Russell 2532: 2528: 2524: 2521:The original 2519: 2517: 2513: 2511: 2507: 2503: 2499: 2495: 2490: 2488: 2478: 2476: 2471: 2467: 2464: 2460: 2456: 2452: 2449: 2444: 2425: 2344:(*scope A+B*) 2232: 2229: 2225: 2221: 2217: 2213: 2209: 2205: 2201: 2197: 2193: 2192:lexical scope 2186:Lexical scope 2183: 2181: 2169: 2112: 1845: 1831: 1812: 1796: 1792: 1791:dynamic scope 1788: 1784: 1780: 1776: 1775:lexical scope 1771: 1762: 1760: 1756: 1752: 1748: 1747: 1742: 1732: 1729: 1724: 1719: 1717: 1713: 1709: 1705: 1695: 1682: 1680: 1676: 1666: 1664: 1658: 1643: 1641: 1595: 1448: 1446: 1442: 1438: 1434: 1430: 1426: 1421: 1416: 1414: 1410: 1406: 1402: 1398: 1397: 1392: 1382: 1302: 1298: 1296: 1282:'foo' 1242: 1208: 1175:'foo' 1141: 1138: 1090: 1088: 1083: 1068: 1066: 1062: 1058: 1053: 1049: 872: 869: 865: 861: 857: 853: 843: 841: 837: 832: 829: 791: 751: 733: 729: 725: 712: 708: 707: 702: 698: 694: 684: 674: 673: 655: 652:and requires 649: 640: 637: 635: 634:syntax errors 631: 627: 623: 619: 615: 610: 608: 604: 600: 599: 593: 583: 579: 575: 570: 568: 564: 560: 556: 552: 547: 545: 541: 537: 533: 528: 526: 522: 518: 515: 512: 508: 504: 500: 496: 492: 489: 483: 473: 471: 467: 463: 462:scoping rules 459: 455: 451: 441: 439: 435: 430: 426: 422: 417: 415: 411: 407: 403: 393: 391: 387: 383: 382:early binding 379: 374: 372: 368: 363: 361: 357: 353: 350:(also called 349: 345: 344:program state 341: 340:dynamic scope 337: 334:(also called 333: 329: 326:(also called 325: 324:lexical scope 315: 313: 309: 305: 296: 293: 290: 288: 284: 279: 275: 272: 269: 265: 262: 261: 260: 258: 254: 244: 242: 238: 234: 230: 226: 222: 218: 214: 208: 206: 202: 201:dynamic scope 198: 194: 190: 189:lexical scope 186: 182: 177: 175: 171: 167: 162: 160: 156: 151: 147: 143: 139: 135: 124: 121: 113: 110:December 2008 102: 99: 95: 92: 88: 85: 81: 78: 74: 71: â€“  70: 66: 65:Find sources: 59: 55: 49: 48: 43:This article 41: 37: 32: 31: 19: 18:Dynamic scope 6065: 6030: 6004:. Retrieved 6000: 5991: 5983: 5976:. Retrieved 5972: 5963: 5943: 5936:. Retrieved 5931: 5919: 5911: 5904:. Retrieved 5899: 5889: 5874: 5867:. Retrieved 5860:MACLISP.info 5859: 5849: 5841: 5834:. Retrieved 5830:MACLISP.info 5829: 5819: 5806: 5794: 5783: 5770: 5757: 5745:. Retrieved 5742:MDN Web Docs 5741: 5732: 5720:. Retrieved 5716: 5707: 5696: 5683: 5671:. Retrieved 5667: 5658: 5646:. Retrieved 5642: 5633: 5625: 5616: 5594:Google Books 5592:, p. 80, at 5587: 5578: 5571:Google Books 5569:, p. 18, at 5564: 5555: 5536: 5530: 5518:. Retrieved 5514: 5504: 5495: 5489: 5480: 5474: 5439: 5433: 5420: 5407: 5396:. Retrieved 5376: 5367: 5358: 5331: 5327: 5317: 5306:. Retrieved 5296: 5243: 5234: 5214: 5201: 5188: 5171: 5163: 5159: 5154: 5141: 5022: 4928: 4834: 4779: 4733: 4718: 4569: 4462: 4298: 4193: 4084: 4065: 4004: 3992: 3980: 3962: 3948: 3926: 3915: 3909: 3899: 3897: 3893: 3756: 3751: 3748: 3669: 3667: 3661: 3657: 3653: 3638: 3612: 3607: 3602: 3504: 3490: 3489:also called 3472: 3466: 3455: 3338: 3326: 3322: 3313: 3307: 3141: 3137: 3125:object files 3122: 3107: 3102: 3098: 3094: 3088: 3086: 3072: 3059: 3055:adding to it 3050: 3019: 3011: 3003: 2991: 2989: 2984: 2980: 2975: 2972: 2968: 2811: 2796: 2778: 2773:preprocessor 2766: 2748: 2741: 2737: 2728: 2724: 2717: 2679: 2668: 2665: 2660: 2649:control flow 2632: 2630: 2614: 2608: 2603: 2602: 2596: 2590: 2586: 2584: 2576: 2570: 2564: 2559: 2553: 2549: 2543: 2527:Deep binding 2526: 2520: 2514: 2491: 2484: 2475:compile time 2465: 2445: 2426: 2363: 2200:static scope 2199: 2191: 2189: 2113: 1965: 1829: 1810: 1794: 1790: 1786: 1783:static scope 1782: 1778: 1774: 1772: 1768: 1744: 1741:global scope 1740: 1738: 1735:Global scope 1720: 1704:module scope 1703: 1701: 1698:Module scope 1683: 1674: 1672: 1659: 1644: 1639: 1596: 1561: 1432: 1428: 1424: 1419: 1417: 1394: 1390: 1388: 1352: 1299: 1292: 1240: 1218:"" 1206: 1139: 1128: 1124:"" 1084: 1069: 1054: 1050: 1046:ret += n * n 1027: 855: 849: 839: 833: 830: 731: 727: 723: 704: 696: 690: 670: 650: 646: 638: 611: 607:logic errors 598:name masking 596: 594: 578:name binding 571: 548: 540:wild pointer 529: 520: 516: 513: 510: 502: 498: 494: 490: 487: 485: 461: 457: 447: 438:transclusion 418: 399: 390:late binding 389: 381: 378:compile time 375: 364: 359: 355: 351: 347: 339: 335: 331: 328:static scope 327: 323: 321: 301: 286: 282: 250: 225:name masking 221:interpreting 209: 200: 188: 178: 173: 169: 165: 163: 158: 142:name binding 137: 131: 116: 107: 97: 90: 83: 76: 64: 52:Please help 47:verification 44: 5978:October 20, 5950:dynamic-let 5938:October 20, 5932:ISLISP.info 5906:October 20, 5869:October 20, 5836:October 20, 5738:"Functions" 5546:1721.1/6913 5515:Paul Graham 5287:Borning A. 5103:environment 4315:means that 3972:dynamic-let 3950:Common Lisp 3877:' ' 3752:scope chain 3654:Initialiser 3608:scope rules 3606:has simple 3416:fileprivate 3246:'b' 3180:'m' 3034:By language 3016:Standard ML 2783:, used for 2689:Common Lisp 2617:Project MAC 2554:Common Lisp 2461:, variable 2448:first-class 2353:(*scope A*) 1137:statement. 856:block scope 846:Block scope 711:Standard ML 458:scope rules 434:inheritance 308:declaration 185:source code 174:environment 5946:defdynamic 5789:2010-02-08 5780:Ben Cherry 5702:2010-02-08 5609:Scott 2009 5520:5 February 5398:2019-04-30 5334:(5): 299. 5308:2015-01-04 5248:WG14 N1256 5226:References 5147:definition 4066:Note that 3983:Emacs Lisp 3968:defdynamic 3856:newCounter 3769:newCounter 3630:ECMAScript 3604:JavaScript 3599:JavaScript 3498:Parameters 3481:loop ends. 3095:visibility 3062:April 2013 3012:structures 2992:namespaces 2713:PowerShell 2697:Emacs Lisp 2544:All early 2228:C language 2196:call stack 1759:namespaces 1755:data types 1675:file scope 1669:File scope 1401:subroutine 1255:'' 1196:'' 701:functional 693:expression 532:references 525:call stack 480:See also: 466:namespaces 425:JavaScript 253:identifier 247:Definition 205:definition 159:visibility 80:newspapers 6063:(2009) . 6036:MIT Press 5973:EmacsWiki 5876:*FUNCTION 5864:*FUNCTION 4973:<<- 3956:, as did 3944:*FUNCTION 3680:undefined 3676:undefined 3660:when the 3646:undefined 3546:protected 2380:variable 2372:variable 2308:procedure 2272:procedure 2174:and then 2162:and then 2150:(because 2134:and then 2122:(because 1610:can call 1580:square(4) 1379:$ counter 1371:$ counter 1355:$ counter 1339:$ counter 1312:$ counter 1065:for loops 1034:n_squared 1005:n_squared 981:n_squared 681:undefined 421:AngularJS 217:compiling 197:execution 6097:Category 6006:19 March 5747:19 March 5722:19 March 5673:19 March 5648:19 March 5466:14517358 5389:Archived 5369:defined. 5043:function 4949:function 4855:function 4800:function 4610:nonlocal 4572:nonlocal 4309:global x 4305:nonlocal 4000:nonlocal 3808:function 3766:function 3758:Closures 3699:function 3521:Subclass 3512:Modifier 3399:internal 3348:Modifier 3311:m m b m 3285:"%c 3258:"%c 3219:"%c 3192:"%c 3147:#include 3004:packages 2657:run-time 2506:ALGOL 68 2502:ALGOL 60 2487:ALGOL 60 2212:Modula-2 2094:, calls 2042:function 1989:function 1907:function 1870:function 1721:In some 1057:Algol 68 975:unsigned 930:unsigned 906:unsigned 891:unsigned 876:unsigned 860:ALGOL 60 788:, or in 726:x = f() 717:returns 612:Various 590:nonlocal 551:lifetime 536:pointers 507:run time 495:context. 476:Overview 386:run time 371:closures 306:—when a 304:variable 298:package. 257:ALGOL 60 241:closures 233:hoisting 193:run time 146:variable 5997:"R FAQ" 5954:dynamic 5596:, 1970. 5073:new.env 5052:message 5006:message 4979:message 4958:message 4912:message 4885:message 4864:message 4809:message 4763:message 4281:, line 4269:, line 4195:error: 3976:dynamic 3958:Clojure 3940:closure 3936:Maclisp 3932:SPECIAL 3928:Maclisp 3580:private 3518:Package 3433:private 3133:linkage 3090:linkage 2896:add_two 2827:add_one 2680:reasons 2663:scope. 2661:dynamic 2481:History 2455:closure 2302:integer 2254:integer 2236:program 2224:Haskell 1751:classes 1663:closure 724:let val 721:, then 491:extent, 283:visible 278:typedef 170:context 150:program 94:scholar 6073:  6042:  5952:, and 5464:  5454:  5350:278290 5348:  5160:extent 5118:my_env 5079:my_env 5067:my_env 4709:global 4576:global 4565:global 4499:global 4464:global 4446:global 4434:global 4377:global 4321:global 4301:global 4189:global 4159:global 4061:global 3996:global 3989:Python 3964:ISLISP 3954:Scheme 3918:Scheme 3838:return 3826:return 3529:public 3524:World 3491:fields 3382:public 3291:" 3279:printf 3264:" 3252:printf 3225:" 3213:printf 3198:" 3186:printf 3129:linker 2985:nested 2711:, and 2671:blocks 2592:Scheme 2531:Funarg 2494:Pascal 2470:nested 2463:lookup 2208:Pascal 1716:Modula 1691:static 1612:square 1586:, and 1572:square 1564:square 1554:return 1533:square 1467:return 1455:square 1333:return 1129:where 1014:return 864:Pascal 730:x * x 586:global 555:extent 488:scope, 410:method 312:labels 294:(2013) 287:scope. 273:(2007) 267:valid. 231:, and 136:, the 96:  89:  82:  75:  67:  5928:(PDF) 5622:Scope 5462:S2CID 5392:(PDF) 5385:(PDF) 5346:S2CID 5177:Jinja 5164:scope 5133:Notes 5115:<- 5088:<- 5070:<- 5040:<- 5031:<- 4946:<- 4937:<- 4879:<- 4852:<- 4843:<- 4797:<- 4788:<- 4754:<- 4742:<- 4697:print 4655:print 4508:print 4386:print 4347:print 4285:, in 4277:File 4273:, in 4265:File 4215:print 4177:print 4147:print 4117:print 4025:print 3922:ALGOL 3862:alert 3711:alert 3625:const 3515:Class 3340:Swift 3335:Swift 3329:allow 2944:ADD_A 2917:const 2875:ADD_A 2848:const 2803:ADD_A 2771:in a 2749:With 2701:LaTeX 2637:stack 2631:With 2546:Lisps 2332:begin 2204:ALGOL 2190:With 2180:ksh93 2052:local 1917:local 1809:does 1632:total 1624:total 1557:total 1527:total 1518:<= 1512:while 1494:total 1042:n * n 972:const 951:<= 888:const 852:block 790:GNU C 713:, if 663:const 140:of a 138:scope 101:JSTOR 87:books 6071:ISBN 6040:ISBN 6008:2018 5980:2018 5940:2018 5908:2018 5871:2018 5838:2018 5749:2018 5724:2018 5675:2018 5650:2018 5522:2020 5452:ISBN 5205:For 5145:See 5127:## 2 5100:## 1 5018:## 2 5003:## 2 5000:## 1 4924:## 1 4909:## 2 4906:## 1 4830:## 1 4775:## 2 4652:... 4643:... 4631:... 4619:... 4607:... 4595:... 4532:... 4520:... 4505:... 4496:... 4484:... 4398:... 4383:... 4374:... 4344:... 4227:... 4212:... 4114:... 4102:... 4022:... 3911:Lisp 3906:Lisp 3886:()); 3622:and 3541:Yes 3468:Java 3463:Java 3365:open 3354:File 3237:char 3171:char 3162:void 3156:main 3028:Java 3024:Perl 3020:also 3010:and 2998:and 2893:void 2824:void 2779:The 2733:LIFO 2709:dash 2705:bash 2693:Logo 2687:and 2685:Perl 2523:Lisp 2516:Perl 2504:and 2496:and 2400:and 2388:and 2378:real 2370:char 2326:real 2290:real 2266:char 2222:and 2214:and 2168:Bash 2101:echo 1999:echo 1952:echo 1880:echo 1830:does 1793:(or 1777:(or 1626:and 1566:and 1184:else 1112:else 866:and 750:Perl 588:and 493:and 460:(or 436:and 73:news 5778:", 5691:", 5628:IBM 5624:", 5586:", 5563:", 5541:hdl 5444:doi 5336:doi 5252:C99 4667:... 4604:(): 4598:def 4592:(): 4586:def 4541:... 4493:(): 4487:def 4481:(): 4475:def 4410:... 4371:(): 4365:def 4359:... 4341:(): 4335:def 4303:or 4239:... 4209:(): 4203:def 4129:... 4099:(): 4093:def 4037:... 4019:(): 4013:def 3998:or 3859:(); 3799:var 3784:var 3744:(); 3723:var 3642:var 3620:let 3592:No 3583:Yes 3575:No 3569:Yes 3566:Yes 3558:No 3555:Yes 3552:Yes 3549:Yes 3538:Yes 3535:Yes 3532:Yes 3445:No 3436:Yes 3428:No 3422:Yes 3419:Yes 3411:No 3408:Yes 3405:Yes 3402:Yes 3391:Yes 3388:Yes 3385:Yes 3374:Yes 3371:Yes 3368:Yes 3319:C++ 3153:int 3093:or 3057:. 3014:in 3008:Ada 3006:in 2996:C++ 2994:in 2920:int 2902:int 2851:int 2833:int 2621:MDL 2609:had 2604:All 2541:). 2512:). 2466:may 2356:end 2347:end 2338:end 2317:var 2281:var 2245:var 2216:Ada 2104:$ x 2035:to 2002:$ x 1955:$ x 1949:$ 1939:$ 1904:$ 1883:$ x 1867:$ 1855:$ 1849:$ 1844:). 1811:not 1785:or 1773:In 1634:or 1594:.) 1479:def 1452:def 1324:sub 1276:$ a 1249:$ a 1190:$ a 1169:$ a 1148:$ a 1061:C99 1017:ret 999:ret 978:int 933:int 924:for 912:ret 909:int 894:int 879:int 810:(); 798:int 792:as 782:$ x 776:$ x 773:(); 764:$ x 752:as 745:f() 737:144 732:end 715:f() 677:var 667:var 661:or 659:let 622:C++ 576:or 561:—a 519:or 501:or 444:Use 400:In 358:or 219:or 172:or 166:all 132:In 56:by 6099:: 6038:. 6024:; 5999:. 5982:. 5971:. 5956:). 5948:, 5942:. 5930:. 5910:. 5898:. 5873:. 5858:. 5840:. 5828:. 5782:, 5740:. 5715:. 5695:, 5666:. 5641:. 5601:^ 5513:. 5460:. 5450:. 5387:. 5344:. 5330:. 5326:. 5278:^ 5269:: 5259:^ 5124:() 5097:() 5082:$ 5076:() 5046:() 4997:() 4952:() 4903:() 4858:() 4827:() 4803:() 4688:() 4649:() 4562:() 4538:() 4455:() 4443:() 4431:() 4292:: 4260:() 4168:() 4058:() 3960:. 3871:() 3835:}; 3820:++ 3811:() 3772:() 3720:); 3705:() 3589:No 3586:No 3572:No 3457:Go 3452:Go 3442:No 3439:No 3425:No 3300:); 3288:\n 3273:); 3261:\n 3234:); 3222:\n 3207:); 3195:\n 3000:C# 2987:. 2956:); 2887:); 2715:. 2707:, 2699:, 2695:, 2573:: 2220:ML 2210:, 2111:. 2046:() 1993:() 1911:() 1874:() 1592:30 1584:16 1570:. 1548:+= 1530:+= 1491:): 1464:): 1447:. 1359:my 1336:++ 1309:my 1261:if 1246:my 1221:if 1154:if 1145:my 1135:if 1094:if 1002:+= 963:++ 828:. 825:}) 795:({ 761:my 755:do 728:in 719:12 683:. 636:. 404:, 392:. 354:, 292:Go 243:. 227:, 176:. 6079:. 6048:. 6010:. 5810:" 5787:, 5774:" 5761:" 5751:. 5726:. 5700:, 5687:" 5677:. 5652:. 5620:" 5582:" 5559:" 5549:. 5543:: 5524:. 5468:. 5446:: 5424:" 5411:" 5401:. 5352:. 5338:: 5332:3 5311:. 5183:. 5121:f 5112:) 5109:f 5106:( 5094:f 5091:2 5085:a 5064:} 5061:) 5058:a 5055:( 5049:{ 5037:f 5034:1 5028:a 5015:) 5012:a 5009:( 4994:f 4991:} 4988:) 4985:a 4982:( 4976:2 4970:a 4967:) 4964:a 4961:( 4955:{ 4943:f 4940:1 4934:a 4921:) 4918:a 4915:( 4900:f 4897:} 4894:) 4891:a 4888:( 4882:2 4876:a 4873:) 4870:a 4867:( 4861:{ 4849:f 4846:1 4840:a 4824:f 4821:} 4818:) 4815:a 4812:( 4806:{ 4794:f 4791:1 4785:a 4772:) 4769:a 4766:( 4760:} 4757:2 4751:a 4748:{ 4745:1 4739:a 4724:S 4720:R 4715:R 4706:) 4703:x 4700:( 4691:g 4685:f 4676:= 4673:x 4664:) 4661:x 4658:( 4646:g 4637:= 4634:x 4625:= 4622:x 4613:x 4601:g 4589:f 4559:f 4550:= 4547:x 4535:g 4526:= 4523:x 4517:) 4514:x 4511:( 4502:x 4490:g 4478:f 4458:g 4452:f 4440:g 4428:f 4419:= 4416:x 4404:= 4401:x 4395:) 4392:x 4389:( 4380:x 4368:g 4356:) 4353:x 4350:( 4338:f 4325:f 4317:x 4313:g 4287:f 4283:2 4271:1 4257:f 4248:= 4245:x 4233:= 4230:x 4224:) 4221:x 4218:( 4206:f 4186:) 4183:x 4180:( 4171:f 4165:f 4156:) 4153:x 4150:( 4138:= 4135:x 4126:) 4123:x 4120:( 4108:= 4105:x 4096:f 4076:f 4072:f 4068:x 4055:f 4046:= 4043:x 4034:) 4031:x 4028:( 4016:f 3883:c 3880:+ 3874:+ 3868:c 3865:( 3853:= 3850:c 3847:} 3844:; 3841:b 3832:; 3829:a 3823:; 3817:a 3814:{ 3805:= 3802:b 3796:; 3793:0 3790:= 3787:a 3775:{ 3741:f 3738:} 3735:; 3732:2 3729:= 3726:a 3717:a 3714:( 3708:{ 3702:f 3696:; 3693:1 3690:= 3687:a 3303:} 3297:x 3294:, 3282:( 3276:} 3270:x 3267:, 3255:( 3249:; 3243:= 3240:x 3231:x 3228:, 3216:( 3210:{ 3204:x 3201:, 3189:( 3183:; 3177:= 3174:x 3168:{ 3165:) 3159:( 3077:C 3064:) 3060:( 2959:} 2953:x 2950:* 2947:( 2941:= 2938:x 2935:* 2932:; 2929:2 2926:= 2923:a 2914:{ 2911:) 2908:x 2905:* 2899:( 2890:} 2884:x 2881:* 2878:( 2872:= 2869:x 2866:* 2863:; 2860:1 2857:= 2854:a 2845:{ 2842:) 2839:x 2836:* 2830:( 2814:a 2799:a 2653:x 2645:x 2641:x 2498:C 2441:C 2437:C 2433:B 2429:C 2422:B 2418:C 2414:B 2410:C 2406:M 2402:C 2398:B 2394:L 2390:C 2386:B 2382:K 2374:K 2366:I 2359:. 2350:; 2341:; 2329:; 2323:: 2320:M 2314:; 2311:C 2305:; 2299:: 2296:L 2293:; 2287:: 2284:K 2278:; 2275:B 2269:; 2263:: 2260:K 2257:; 2251:: 2248:I 2242:; 2239:A 2176:1 2172:3 2164:1 2160:3 2156:f 2152:g 2148:x 2144:f 2140:g 2136:2 2132:1 2128:f 2124:g 2120:x 2116:g 2109:x 2096:f 2092:f 2088:g 2084:3 2080:x 2076:f 2071:} 2068:; 2066:g 2064:; 2061:3 2058:= 2055:x 2049:{ 2044:f 2037:2 2033:x 2029:x 2025:g 2020:} 2017:; 2014:2 2011:= 2008:x 2005:; 1996:{ 1991:g 1984:1 1980:x 1975:1 1972:= 1969:x 1961:1 1946:3 1941:f 1936:} 1933:; 1931:g 1929:; 1926:3 1923:= 1920:x 1914:{ 1909:f 1901:} 1898:; 1895:2 1892:= 1889:x 1886:; 1877:{ 1872:g 1864:1 1861:= 1858:x 1842:f 1838:g 1834:f 1827:g 1823:f 1819:g 1815:f 1807:g 1803:g 1799:f 1655:n 1651:n 1647:n 1636:i 1628:i 1616:n 1603:n 1599:n 1551:1 1545:i 1542:) 1539:i 1536:( 1524:: 1521:n 1515:i 1509:0 1506:= 1503:i 1500:0 1497:= 1488:n 1485:( 1476:n 1473:* 1470:n 1461:n 1458:( 1348:} 1345:} 1342:; 1330:{ 1321:; 1318:0 1315:= 1306:{ 1288:} 1285:; 1279:= 1273:{ 1270:) 1267:c 1264:( 1258:; 1252:= 1233:= 1230:a 1227:: 1224:c 1215:= 1212:a 1202:} 1199:; 1193:= 1187:{ 1181:} 1178:; 1172:= 1166:{ 1163:) 1160:c 1157:( 1151:; 1131:a 1121:= 1118:a 1115:: 1106:= 1103:a 1100:: 1097:c 1080:n 1076:n 1072:n 1038:i 1030:n 1023:} 1020:; 1011:} 1008:; 996:; 993:n 990:* 987:n 984:= 969:{ 966:) 960:n 957:; 954:N 948:n 945:; 942:1 939:= 936:n 927:( 921:; 918:0 915:= 903:{ 900:) 897:N 885:( 868:C 822:; 819:x 816:* 813:x 807:f 804:= 801:x 785:} 779:* 770:f 767:= 758:{ 741:x 509:( 271:C 123:) 117:( 112:) 108:( 98:· 91:· 84:· 77:· 50:. 20:)

Index

Dynamic scope

verification
improve this article
adding citations to reliable sources
"Scope" computer science
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
computer programming
name binding
variable
program
name collisions
programming languages
source code
run time
execution
definition
implementation
compiling
interpreting
name masking
forward declarations
hoisting
non-local variables
closures

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

↑