Re:Fengari – Lua for the Browser
by boardwaalk on Sunday February 20, 2022 @10:47AM
(#30406574)
It even does this for globals (which are just another table), so there’s never an “undefined variable” error (even though there really is).
It’s pretty unfortunate. You can mitigate it using meta tables though.
Give Teal [1] a look. It’s basically typescript for Lua
Storing a null value is a legitimate operation. How do you distinguish "never stored a value under key K", and "stored null under key K"?
This is not necessarily a bad choice. Exceptions and such can be a real pain. However, accidentally getting a null value because you didn't check and then have it propagate much further in your program is extremely difficult to debug. Instead of blowing up at the site of the bad lookup, you only see the distant effects of it (e.g. put the null value into another table, which gets put in another table, and then is attempted to be called as a function, etc).