lua-users home
lua-l archive

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

> 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