lua-users home
lua-l archive

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


On Sun, Apr 4, 2010 at 6:32 PM,  <lua@zevv.nl> wrote:
> Hello,
>
> In our application framework I'd like to be able to load multiple source
> files in the same scope to be able to access local variables between
> source files while avoiding explicit namespace or globals. A naive
> approach is to just read all source files, concatenate and pass to
> loadstring(). This works just fine, but has the disadvantage that
> debugging symbols do no longer point to the right line numbers, messing
> up error messages and stack backtraces.
>
> Is there a simple method to accomplish the above without this problem ?
>
> Thank you,
>
>

(This isn't a solution, I'm just trying to understand your situation a
bit better:) Where are these shared local variables defined? I mean,
if all your scripts have their own "local var1" statement then they
will all have their own independent var1, anyway - and you say that
the concatenation approach works semantically. Do your scripts have a
natural sequence in which they should be ordered, so you can
confidently have a "local var1" in one script, knowing that any other
scripts that refer to var1 will come later, not earlier?

-Duncan