lua-users home
lua-l archive

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


I wrote a Lua 5.1 module (in C) to test a certain C library. I mantain a few
'state' global variables (in the C fashion):

static int _traceEnabled;
static int _updateMode;
// such...

This is not a __very__ bad thing since it's just a testing purpose module
and it is pretty much self-contained.

However, since I have Lua ways to avoid doing this (using environment,
upvalues, and such) I would like to remove the global vars and
replace them with non-local or something.

I would like to have an environment value easily accesible local
to the module or local to a specific function but I am not sure how 
this is done.

Maybe lua_setfenv()? but I can't find clear documentation (Besides
it seems it will be removed in 5.2).

Any guidance?

Thanks in advance,
Ezequiel.