|
Le 01/07/2014 16:33, Choonster TheMage a écrit :
It does not seems to work for 5.2 unfortunately:On 2 July 2014 00:04, David Demelier <demelier.david@gmail.com> wrote:
Le 01/07/2014 15:08, Andrew Starks a écrit :For me, one of the only thing I do agree is that the lack of static analysis can lead to bugs. In Lua if I type:
http://programmers.stackexchange.com/questions/221615/why-do-dynamic-languages-make-it-more-difficult-to-maintain-large-codebases
Told from the perspective of _javascript_, but most of it applies to Lua, as well.
-Andrew
print(unexistant)
The code will obviously load as there are no syntax error, but will fail at the execution since unexistant is not a defined variable. In C++, you will actually have an error at the compilation. For that issue, you can only check at runtime and personally, it's the only problem I have when I develop irccd [1] plugins.
Cheers,
David.
[1] http://projects.malikania.fr/irccd
There are tools like FindGlobals[1] that analyse the output of luac to detect global variable access (intentional or otherwise). FindGlobals also allows you to whitelist certain global names so they don't show up in the output.
FindGlobals is only for Lua 5.1, but it could probably be easily adapted for 5.2. I'm pretty sure there are existing alternatives for 5.2, but I can't think of their names at the moment.
Although FindGlobals is distributed from a World of Warcraft AddOn site, it's meant to run in a standard Lua 5.1 environment (and in fact can't run inside WoW's embedded Lua due to sandbox restrictions).
~/test $ cat test.lua
print(failed)
~/test $ luac52 -l -p test.lua|lua52 findglobals/globals.lua test.lua
~/test $
Regards,
David.