[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: upvalues actually are values?
- From: Coda Highland <chighland@...>
- Date: Tue, 23 Oct 2012 11:14:55 -0700
On Tue, Oct 23, 2012 at 11:01 AM, spir <denis.spir@gmail.com> wrote:
> The reason is that so-called upvalues usually not are values, but "up-vars".
Lua's are "up-vars" too. This is a fact that's noted in a couple
places (I think there's some discussion in PiL) -- "upvalue" is an
unfortunately inaccurate name kept around for historical reasons.
But yes, as Geoff mentioned, your global "i" variable there is NOT
included in the generated closure because it's shadowed by the "i"
parameter to inc().
Semantically: Lua's closures can be thought of as searching for each
free variable in each enclosing scope until a definition is found, and
then keeping a reference to that.
/s/ Adam