lua-users home
lua-l archive

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

Follows a nice script to detect missing "local" declarations and other
"wrong" uses of global variables.

Simply put it in your path and add  require"strict" to your program
(or call "lua -lstrict").

-- Roberto

-- strict.lua
-- checks uses of undeclared global variables
-- All global variables must be 'declared' through a regular assignment
-- (even assigning nil will do) in a main chunk before being used
-- anywhere or assigned to inside a function.

Excellent. Thanks.
Are there considerations for a future major release to have this strict behaviour a default of the language? Wouldn't it considerably help using mainly local variables except where global trully intended? Could this strictness be enforced (by default in a future major version or optionally in a future minor version) at byte-code compile time?

Olivier Mascia