[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Alternatives to C function environments
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 10 Mar 2014 11:10:50 -0300
> Is the concept of upvalues the only current alternative to the C
> function environments feature previously available in Lua 5.1?
Yes. Tipically, you can open your library with code like this:
luaL_newlibtable(L, funclist); /* create table for library */
lua_newtable(L); /* create table T for upvalue */
luaL_setfuncs(L, funclist, 1);
That will add all functions from list 'funclist' into the new library,
all sharing table T as an upvalue. Then, you can use this upvalue
as you used the old environment.
-- Roberto