[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: How to test if a userdata has an environment table
- From: Gaspard Bucher <gaspard@...>
- Date: Tue, 11 Jan 2011 01:40:23 +0100
Hi there,
I am reading the docs over and over and I do not see how I am supposed to see if the userdata has it's own environment table...
I see that "userdata and C functions are created sharing the environment of the creating C function" and that "the environment of the running C function is always at pseudo-index LUA_ENVIRONINDEX".
So my guess is to do this:
// ... <userdata>
lua_getfenv(L, -1);
// ... <userdata> <env>
if (lua_rawequal(L, -1, LUA_ENVIRONINDEX) {
// does not have it's own env table
Is this ok ?
Gaspard