Hacker News new | ask | show | jobs
by copx 4680 days 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
1 comments

Trading the ability to have multiline expressions for the ability to skip "return" sounds like a bad deal.