lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Chris Marrin wrote:
John Belmonte wrote:
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.

I think upvalue is a completely reasonable and clear term. Any terminology used will be obtuse to those new to the language. So it is better to have a short and easy-to-remember. I find "inherited binding reference" to be at least as obtuse as upvalue :-)

Perhaps, to satisfy purists and plain "dumb" users (like me), it is enough to define early that in this manual, "upvalue" term is used as a synonym to "inherited binding reference" with a proper expanded definition (perhaps clearer than the above one, which may be precise, but a bit obscure for my dumb brain). And continue to use the upvalue term to which we are beginning to accustomed.

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --