strictness
strictness copied to clipboard
Tracks accesses and assignments of undefined variables in Lua
strictness
With the Lua programming language, undeclared variables are not detected until runtime, as Lua will not complain when loading code.
This is releated to the convention that Lua uses : global by default. In other words, when a variable is not recognized as local, it will be
interpreted as a global one, and will involve a lookup in the global environment _G
(for Lua 5.1). Note that this behaviour has been removed starting from Lua 5.2, which strictly speaking has no globals, because of its lexical scoping.
strictness is a module to track access and assignment to undefined variables in your code. It enforces to declare globals and modules variables before assigning them values. As such, it helps having a better control on the scope of variables across the code.
strictness is mostly meant to work with Lua 5.1, but it is compatible with newer versions of Lua.
##Installation
####Git
git clone git://github.com/Yonaba/strictness
####Download
- See releases
####LuaRocks
luarocks install strictness
####MoonRocks
moonrocks install strictness
or
luarocks install strictness --server=http://rocks.moonscript.org strictness
Documentation
See tutorial.md.
##Tests
This project has specification tests. To run these tests, execute the following command from the project root folder:
lua spec/tests.lua
##Similar projects
Feel free to check those alternate implementations, from with strictness takes some inspiration:
- strict.lua which is included in the official Lua 5.1 distribution,
- pl.strict which is part of Penlight,
##License
This work is under MIT-LICENSE
Copyright (c) 2013-2014 Roland Yonaba.
See LICENSE.