lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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.