|
Something like
function fn(s)
local args, body = s:match "^%s(%b())(.+)$"
return (loadstring or load)("return function "..args.." return " ..body.." end")
end
print (fn "(a, b) a + b" (1, 2)) -- 3
Would work too, no need to overload operators.