I am in a pure Lua 5.2 environment and I need to execute Lua 5.1 code. This code is arbitrary code from the user, so I can't port to Lua 5.2 in advance. As far as I can see, this would entail reimplementing getfenv/setfenv, changing the _VERSION string, hiding the global _ENV and reimplementing the removed deprecated features. Have I missed anything, or is there a better way to go about doing this? (I can only write code in pure Lua, and I need to be able to execute 5.1 code as this is meant to be a backwards-compatibility thing.)
1 Answers
0
votes
This may be a hard to do in full generality, but there are partial solutions that may work for you.
For a compatibility layer, see lua-compat-env.
For further discussion and other solutions, see Lua Version Compatibility.
loadwith Lua 5.1 byte code. If you can do with less, see lua-users.org/wiki/LuaVersionCompatibility ; in particular, github.com/davidm/lua-compat-env. - lhf