strict.lua is a script included in the Lua 5.1.4/5.1.5 distribution package, and through its use, errors due to global variable typos can be prevented, to some extent.
- When attempting to reference a global variable for which the value is un-configured
- When attempting to configure the value of the first global variable within a function.
When using strict.lua, it will be possible to regard configuring values for global variables in the main chunks outside of all of the functions as “declaration of global variables.” If you try to use an undeclared global variable, since strict.lua will cause an error, it is become possible to detect when you are attempting to use a mistaken global variable with a typo.
[When strict.lua is not used]
[When strict.lua is used]
With strict.lua, because errors are first detected when attempting to execute code, errors in unexecuted parts when tests are conducted cannot be detected. You will need to devise test cases to execute all of the code.
Additionally strict.lua manipulates the _G global variable’s meta table. For this reason, there is a possibility that it will not work well by butting with the other libraries that operate the meta table of _G.