Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As eval() was removed from Lua, you must reimplement it:

  ```
  function eval(s)
    load(s)()
  end

  ```



For those who don't know Lua very well (like me), here is a link to the reference manual.

https://www.lua.org/manual/5.4/manual.html#pdf-load

A simple example that I tested:

   local chunk = "return 2 + 2"
   local func = load(chunk)
   print(func())  -- Output: 4


loadstring lwas replaced with load, and dostring was removed, but it's basically just assert(loadstring(code))(...)

load is the replacement.

i assume the grandparent meant dostring and not eval?




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: