I can't seem to figure out what the benefits and limitations of Locals are. I tried Googling for a Lua site but it didn't really describe it helpfully.
Man, how can you use lua and not know what local variable is XD?
Usually you only use local variables when you only need to store something temporarily. If you always use globals, not only will you be cluttering the global namespace (meaning there will be a lot of variable name conflicts), you are also using more memory than you should be.
Zorbatron wrote:Usually you only use local variables when you only need to store something temporarily. If you always use globals, not only will you be cluttering the global namespace (meaning there will be a lot of variable name conflicts), you are also using more memory than you should be.
Not to mention the speed advantages of using locals.
For example,