lua-users home
lua-l archive

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

It was thus said that the Great Luiz Henrique de Figueiredo once stated:
> > e) Unmaintained with regards to Lua versions - i.e. library was never
> > updated to work with 5.3. The question is whether the library is
> > useful enough to put the effort in upgrading it.
> Is this very frequent? I mean, what in 5.3 prevents a 5.2 or 5.1
> library to run in Lua 5.3?

  First off, module() is no longer in Lua 5.2+, so there's that.  Then there
are some C API changes (not many) that require some work arounds.

  For Lua based modules, I did the following:

	if _VERSION == "Lua 5.1" then
	  _ENV = {}

	-- rest of module

	if _VERSION >= "Lua 5.2" then
	  return _ENV

  And that pretty much did the work.  For the C-based modules, I've found
these work:

#if LUA_VERSION_NUM == 501
#  define lua_rawlen(L,idx)       lua_objlen((L),(idx))
#  define luaL_setfuncs(L,reg,up) luaL_register((L),NULL,(reg)) // [1]
#  define lua_getuservalue(L,idx) lua_getfenv((L),(idx))
#  define lua_setuservalue(L,idx) lua_setfenv((L),(idx))

and this (per module):

#if LUA_VERSION_NUM == 501

  The changes were quite minimal for my stuff.  For others---eh.  One module
I use, LuaXML is a mess.  First, the project is LuaXML. What you use in
require() is "LuaXml", and it pollutes the global namespace (because it's
for Lua 5.1) with "xml" (and expects that to be in the global space or it
won't work).  That one took a bit of effort to get working on Lua 5.2 and


[1]	Or 

#if LUA_VERSION_NUM == 501
#  define luaL_setfuncs(L,reg,up) luaI_openlib((L),NULL,(reg),(up))

	if I have upvalues I need to set.  It may be hacky, but it works.