[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: block return semantic
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 26 Jun 2001 16:29:54 -0300
> It's not possible to wrap any arbitrary block in a return().
But you can try. With the new lua_loadstring, you can try to compile
"return "..inputline, and if there is no errors then you call it and
print the result. Otherwise, you call lua_dostring (without the return).
"It is an expression if it looks like an expression" ;-)
while 1 do
local line = read()
local f = call(loadstring, {"return "..line}, "x", nil)
if f then print(f())
else dostring(line)
end
end
-- Roberto