John D. Ramsdell wrote:
Section 2.4 of the 5.1 beta manual includes the following text:
Because of the lexical scoping rules, local variables can be freely
accessed by functions defined inside their scope. For instance:
local counter = 0
function inc (x)
counter = counter + x
return counter
end
A local variable used by an inner function is called an upvalue, or
external local variable, inside the inner function.
First, let me point out that an upvalue is not a type of value, and an
external local variable is not a type of variable. Confusingly, both
of these terms refer to a type of variable reference. Since Lua is
now lexically scoped, you can use established terms to describe its
scoping rules. Let me suggest the following replacement for the last
paragraph.
In the displayed example, each reference to the variable counter in
the function inc refers to a local variable that is bound outside
the inc function's body. In other words, the variable refers to a
binding inherited from the scope in which the function is defined.
A variable reference that refers to such a binding is called
inherited binding reference.
Roberto, in his talks, freely admits that "upvalue" is not the best
term. However, do we want to replace every instance of "upvalue" in the
C API with "inherited_binding_reference"? Please let's not have another
naming and meaning debate on this as in 2001.