lua-users home
lua-l archive

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

On Thu, Nov 30, 2006 at 01:52:26PM -0800, Wesley Smith wrote:
> obviously myvar won't.  It was my (apparently wrong) understanding
> that local values at global scope would persist at the global level.
> However, this isn't the case.  Where do they exist and to what extent
> do they exist?

I think they exist until the end of their enclosing scope. In your
example, you have a local, then the script ends... that can't actually
be your whole script, it would run and exit. When you load a chunk, it's
like creating an anonymous function. Then when you call the chunk, it
runs, creates the local, finishes the chunk, and any locals are
available for garbage collection...