lua-users home
lua-l archive

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


The call `setfenv(0, my_environ)' changes only the global environment,
that is, the environment used by C functions (and for new chunks). Once
a Lua function is created, it has its own environment; changing the
global environment will not change the environment of any Lua function
created previously. Therefore, the anonymous function that is
calling `setenv', the function `run', and the main chunk each has its
own environment (that happens to be the same table).

Notice also that the environment that a Lua function uses does not
depend on the thread where the function is running: Each function uses
its own environment.

-- Roberto