Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

For those who like to declare their variables

IgnatzIgnatz Mod
edited July 2013 in General Posts: 5,396

I found this link with code (under the first approach described on the page) that prevents you declaring global variables by locking the globals table, so you have to declare all variables locally (unless you unlock globals first).

This is useful in development for catching typos, eg you could lock the global table at the end of setup, when you've declared all the globals you actually need. If you mistype a variable after that, Lua will try to add it to the globals list, fail, and throw an error.

So this forces you to explicitly declare all variables, eg local img

http://lua-users.org/wiki/DetectingUndefinedVariables

Comments

Sign In or Register to comment.