Content deleted Content added
←Created page with 'In programming language theory, a '''non-local variable''' is a variable that is not defined in the local scope. While the term can refer to global variables, i...' |
not is it global |
||
Line 1:
In [[programming language theory]], a '''non-local variable''' is a variable that is not defined in the local scope. While the term can refer to global variables, it is primarily used in the context of nested and anonymous functions where can some variable can be neither in the [[local scope|local]] nor in the [[global scope]].
== Example ==
In the example that follows there is a nested function <code>inner</code> defined in the scope of another function <code>outer</code>. The variable is local to <code>outer</code>, but non-local to <code>inner</code> (nor is it global):
<source lang=python>
def outer():
|