[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: creating and evaluating functions -- Lua 4.0 vs Lua 5.0
- From: Max Ischenko <max@...>
- Date: Wed, 18 Jun 2003 16:55:18 +0300
Hi,
I have this code snippet:
function compile(spec)
local funcBody = string.format('return function() return %s end', spec)
return loadstring(funcBody)
end
f = compile('2==3')
print(f())
This prints 0 on Lua 4.0 and function: 0x804eb60 on Lua 5.0
To print false (a.k.a 0) in Lua 5.0 I had to wrote
print(f()())
Why I this? Did I write compile function wrong?
My goal is to create a Lua function from the user-specified string and
evaluate it.
--
Regards, max.