lua-users home
lua-l archive

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


It looked to me like it uses multiple Lua threads within the same
single main state, not multiple main states - shouldn't they share the
registry and therefore loaded packages?

On 8/9/07, Nick Gammon <nick@gammon.com.au> wrote:
>
> On 02/08/2007, at 5:48 PM, Tom Miles wrote:
>
>
> > We know that the environment 1 code is called before environment 2,
> > yet the results are the ouput is:
> > 1
> > nil
>
>
>  From what I can see of your code you are making multiple Lua states.
> When you "require" something it is like a '#include <file>' in C, you
> get a copy of the code, not a shared state. Thus, the variables in
> Utilities.lua are independent from one state to the next. Of course,
> if you "require" something twice in a single Lua state then its
> variables are shared, because it is being loaded into the same state.
>
> - Nick
>