Non-local variable: Difference between revisions

Content deleted Content added
Ruud Koot (talk | contribs)
top: move upvar from closure, since just a synonym for this (else not relevant for closures)
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 some variables can be neither in the [[local scope|local]] nor the [[global scope]]. Other names
 
In [[Lua (programming language)|Lua]] these are called an ''upvalue'' of the function.<ref>''[http://www.lua.org/pil/contents.html Programming in Lua (first edition)],'' "[http://www.lua.org/pil/27.3.3.html 27.3.3 – Upvalues]"</ref>
 
== Examples == <!-- Please do NOT add the same example in other languages to this article. These examples suffice to get the point across. Wikipedia is not a source code repository. -->