lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Steve brought up Lua gotchas in a different context. I didn't have
> "strict" loaded and had a long bout with a hidden bug, leading me wish
> that strict global creation was a more integral part of Lua.
> 
> ##Motivation and Acknowledgement of Existing Alternatives:
> [...]

I wonder if you have considered any static analysis solutions. A naive approach would be to look for global-related byte codes in the output of `luac`, filtering allowed globals. Also, there are plenty of metalua-based snippets on the wiki page[1]; I'd shamelessly plug my own[2]. 

Static analysis solutions don't slow the program at all, there is no need to worry whether the all code are executed when testing, and assigning a global, if needed, is simply `_G.key = value`. 

> Thanks!
> 
> -Andrew

Peter

[1] http://lua-users.org/wiki/DetectingUndefinedVariables
[2] https://github.com/mpeterv/luacheck