[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Alternatives to C function environments
- From: Camilo Bravo Valdés <faranwath@...>
- Date: Mon, 10 Mar 2014 12:24:08 -0200
I see. Thanks for the quick answer!
On 3/10/14, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>> 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
>
>