Lua Version Compatibility

lua-users home
wiki

Difference (from prior major revision) (no other diffs)

Changed: 4c4
* Bytecode: Lua 5.1 and Lua 5.2.0-alpha are not bytecode compatible, and LuaJit 2.x doesn't support bytecodes. Even within a single version of Lua (5.1), bytecode on different platforms (e.g. Intel x86, Intel x86-64, and PPC) may not be compatible. Source code is more compatible, and source code can be minified (e.g. see squish: CompressionAndArchiving). This typically affects C modules that bundle compiled bytecode (e.g. via BinToCee) and has affected MetaLua.
* Bytecode: Lua 5.1 and Lua 5.2.0-alpha are not bytecode compatible, and LuaJit 2.x doesn't support the standard Lua interpreter's bytecodes. Even within a single version of Lua (5.1), bytecode on different platforms (e.g. Intel x86, Intel x86-64, and PPC) may not be compatible. Source code is more compatible, and source code can be minified (e.g. see squish: CompressionAndArchiving). This typically affects C modules that bundle compiled bytecode (e.g. via BinToCee) and has affected MetaLua.

This page is dedicated to information on ensuring that Lua code remains compatible across multiple versions of Lua (e.g. 5.1 and LuaFiveTwo), as well as different LuaImplementations.

#define LUA_VERSION	"Lua 5.1"
#define LUA_RELEASE	"Lua 5.1.4"
#define LUA_VERSION_NUM	501

There are reasons to prefer capability detection over version detection [5]. Doing tests like _VERSION == "Lua 5.2" will almost certainly break in 5.3. _VERSION ~= "Lua 5.1" will more likely be forward compatible, though will break in 5.0 (if that matters).

RecentChanges · preferences
edit · history
Last edited March 1, 2014 12:44 pm GMT (diff)