5 ms·
Here is a hacky "REPL" of sorts in Lua: while true do io.write("> ") exp = io.read() print((loadstring("return " .. exp) or loadstring(exp))())
by copx 13y ago
Here is a hacky "REPL" of sorts in Lua:
while true do
io.write("> ")
exp = io.read()
print((loadstring("return " .. exp) or loadstring(exp))())
end
Actually kinda works. Example session:
> 5 + 5
10
> msg = "Hello"
> print(msg)
Hello
> double = function(x) return x * 2 end
> double(2)
4
> a = 4
> b = a + 5
> b
9
- anonymoushn 13y agoTrading the ability to have multiline expressions for the ability to skip "return" sounds like a bad deal.