lua-users home
lua-l archive

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


2014-09-01 7:21 GMT+02:00 Philipp Janda <siffiejoe@gmx.net>:

> and the code doesn't even build for Lua 5.1 without compatibility switches
> on (because it uses `luaL_reg`). I don't know how much work it would be to
> port it to Lua 5.2.

If the original library is well disciplined (i.e. the module table is returned,
and beyond the one inevitable entry, which even in 5.2 "lua -l modname"
gives, there is no pollution of _G), I have usually found it sufficient
to replace one call to luaL_register(L,"modname",funcs) by
   lua_newtable(L);
   lua_setfuncs(L,funcs,0);
and possibly several calls to luaL_register(L,NULL,subfuncs) by
   lua_setfuncs(L,subfuncs,0);

Unfortunately there are some small subtleties, and one may need
to consult

   $TGZDIR/lua-5.2.3/doc/manual.html#8.3