Content deleted Content added
implementation issues |
No edit summary |
||
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 function|nested]] and [[anonymous function]]s where can some
== 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 <code>x</code) is local to <code>outer</code>, but non-local to <code>inner</code> (nor is it global):
<source lang=python>
def outer():
Line 13:
</source>
In this next example the variable c is non-local in the anonymous function <code>\x -> x + c</code>:
<source lang=haskell>
outer = let c = 1 in map (\x -> x + c) [1, 2, 3, 4, 5]
|