logoalt Hacker News

ptxtoday at 9:41 AM1 replyview on HN

Lua's variables being global by default seems somewhat error-prone.


Replies

gucci-on-fleektoday at 9:47 AM

Agreed, but the recently-released v5.5 fixes that [0], and it's fairly easy to fix this in older versions with the following snippet

  setmetatable(_G, { __newindex = false, __index = false })
[0]: https://www.lua.org/manual/5.5/manual.html#2.2