lua-users home
lua-l archive

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


2008/3/31, Shmuel Zeigerman <shmuz@actcom.co.il>:
> Is there some reason behind enforcing userdata environment to be a table?

I'm very surprised by the question, and the rest of the thread. In
some of my modules I use full userdata as the environment to other
full userdata, I never ran into an error specifying that the
environment has to be a table.

More specifically, my userdata A is a pointer to a C structure, and
when I __index one of its field, it returns a userdata B pointing to
the field directly. To avoid the A structure to be collected while I
have a pointer to its field (B), I make A the environment of B. It
seems to work perfectly fine.

How should the restriction manifest itself ? Is that something
specific to the Lua version of setfenv (as opposed to the C function
lua_setfenv) ? Is that something from Lua 5.0 (I'm using 5.1) ?