lua-users home
lua-l archive

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

On Mon, Nov 30, 2009 at 12:41 PM, spir <> wrote:
> Follow-up. Just for curiosity.
> This seems to show upvalues are referenced by names (what I called symbolic reference) rather than by address (pointer reference). Else the full replacement of t would not be seen by the closure, as its address has changed.
> Is this interpretation correct?

what i find easiest to understand, is that 't' is the_same_variable
thorough it's whole scope, not different 'pointers' to the same value.

that's what's meant by 'lexical scoping': which variables you can
access is determined by where is the code written, not when it's
executed (that's called 'dynamic scoping').   so, it doesn't matter
when g() is executed, what matters is that its code is inside the
scope of the 't' variable. therfore, it can 'see' the very same 't'