lua-users home
lua-l archive

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

> What I mean is this: are this variables accessed from inner function
> are in fact upvalues, that got rid of %? And what about old upvalues?
> Are they still available for backward compatibility?

Yes, it is an upvalue.  The %-syntax is no longer supported.  The good part
is that upvalues are now mutable (so you can assign to an upvalue) and can
reference locals in _any_ enclosing scope.  As long as the local is still in
scope (in its defining scope) it will actually be changed by assigning to a
corresponding upvalue.  When the local variable goes out of scope, any
closure that referred to it will be "closed", i.e. the local value will be
copied over from the stack into a private structure.  It remains mutable and
is still shared among all closures using that same upvalue.  So from the
closure's viewpoint, nothing changes after it is closed.

Upvalues to globals are (in my understanding) no longer supported.