Home

Awesome

<b><span style="color: red">This repository is now archived. Consider using</span> http://github.com/lunarmodules/lua-compat-5.3</b>

lua-compat-5.2

Lua-5.2-style APIs for Lua 5.1.

What is it

This is a small module that aims to make it easier to write code in a Lua-5.2-style that is compatible with both Lua 5.1 and Lua 5.2. This does not make Lua 5.1 entirely compatible with Lua 5.2, but it brings the API closer to that of Lua 5.2.

It includes:

Both the Lua module and the C files should also work with LuaJIT.

How to use it

Lua module

require("compat52")

You have to launch it like this (instead of the usual idiom of storing the return of require in a local variable) because compat52 needs to make changes to your global environment.

When run under Lua 5.2, this module does nothing.

When run under Lua 5.1, it replaces some of your standard functions and adds new ones to bring your environment closer to that of Lua 5.2.

You may also use the "strict mode" which removes from Lua 5.1 functions that were deprecated in 5.2; that is the equivalent of running Lua 5.2 with the LUA_COMPAT_ALL flag disabled:

require("compat52.strict")

The "strict mode" changes the global environment, so it affects all loaded modules and chunks. If this is undesirable, you can use the "modular strict mode" which only replaces the environment of the current file. The usage is slightly different (you have to call the return value of require):

require("compat52.mstrict")()

The effects of compat52 are still in effect for all chunks, though.

C code

Add the files compat-5.2.c and compat-5.2.h to your project and link it with the rest of your code as usual.

What's implemented

Lua

C

What's not implemented

See also

Credits

This package contains code written by: