[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How access local variables with load*() functions
- From: "Aaron Brown" <aaron-lua@...>
- Date: Thu, 8 Sep 2005 16:39:45 -0400
> I just realized that I can't access locals variables with
> aly load*() function (load, loadfile, loadstring, dofile)
> Is that normal ?
> Why ?
Because strings (since they are a chunk of data that can be
passed around anywhere inside a program) are not considered
to be lexically nested within any part of the program, and
local variables are lexically scoped.
> What can I do to access those locals variables ?
Here's one way (that may not be appropriate for what you
want to do):
Lua 5.0.2 Copyright (C) 1994-2004 Tecgraf, PUC-Rio
>> local aa = "bb"
>> loadstring("print('aa = ', " .. string.format("%q", aa) .. ")")()
aa = bb