lua-users home
lua-l archive

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


I have this code snippet:

function compile(spec)
	local funcBody = string.format('return function() return %s end', spec)
	return loadstring(funcBody)

f = compile('2==3')

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

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.