Execute Lua 5.1 code in Lua 5.2 environment

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 cannot pre-push it in Lua 5.2. As far as I can see, this will entail re-executing getfenv / setfenv, changing the _VERSION line, hiding the global _ENV, and overriding removed deprecated functions. Am I missing something, or is there a better way to do this? (I can only write code in pure Lua, and I need to be able to execute 5.1 code as that means it's a backward compatibility thing.)

+3


source to share


1 answer


It can be difficult to do this in full generality, but there are partial solutions that might work for you.

For compatibility level see lua-compat-env .



For further discussion and other solutions see Lua Version Compatibility .

0


source







All Articles