lua-users home
lua-l archive

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

.  It is a bit confusing maybe...

Ok I am confused. The  LUA_ENVIRONINDEX according to the manual is
"The environment of the running C function is always at pseudo-index
LUA_ENVIRONINDEX." (You will note that this the one refernce to it in
Given that the code never sets LUA_ENVIRONINDEX I assume
that it is equal to LUA_GLOBALINDEX.

In this case it was a running *Lua* function in another thread..

Wim  wrote:
Hi David,

>       lua_createtable(L1,0,0);
>       lua_setfenv(L1, funix); /* remove reference to env */

> It would seem that this also set the environment of the function in
> *all* executing threads.

Yes, that's what it is intended to do: change the environment of the
*executing* C function.  To change the environment use lua_replace(L1,
LUA_ENVIRONINDEX).  It is a bit confusing maybe...