11-25-2013, 01:33 AM
No, it cannot, mainly because functions in Lua are really closures - they take with them the local values of their containing functions and are able to modify those; this cannot be safely ported to another Lua state structure. Consider the following example:
function FnOuter(ParamOuter) local VarOuter = 10; local FnInner = function(ParamInner) local VarInner = VarOuter + 1; -- It can read FnOuter's local variables VarOuter = VarOuter * 3; -- It can modify them local VarInner2 = ParamOuter + 1; -- It can even read FnOuter's parameters end SomeOtherFunction(FnInner); -- Perfeclt valid Lua code, SomeOtherFunction() can call FnInner however it wants end