lua-users home
lua-l archive

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


On Sat, Feb 26, 2011 at 18:15, Reuben Thomas <rrt@sc3d.org> wrote:
[...]Looking at the changes to the
language for 5.2, it looks as though it is easily possible to write
scripts that work in both 5.1 and 5.2, and probably quite feasible to
write scripts that work in 5.0-5.2. Hence, arguably, this macro has a
purpose.
 
LPEG is forward compatible:

in lpeg.c :
-----------------------------
/*
** compatibility with Lua 5.2
*/
#if (LUA_VERSION_NUM == 502)

#undef lua_equal
#define lua_equal(L,idx1,idx2)  lua_compare(L,(idx1),(idx2),LUA_OPEQ)

#undef lua_getfenv
#define lua_getfenv lua_getuservalue
#undef lua_setfenv
#define lua_setfenv lua_setuservalue

#undef lua_objlen
#define lua_objlen lua_rawlen

#undef luaL_register
#define luaL_register(L,n,f) \
{ if ((n) == NULL) luaL_setfuncs(L,f,0); else luaL_newlib(L,f); }

#endif

-----------------------------

in re.lua:
-----------------------------
-- No more global accesses after this point
local version = _VERSION
if version == "Lua 5.2" then _ENV = nil end
-----------------------------


-- Pierre-Yves