Search found 2 matches
- Tue Dec 31, 2013 3:19 am
- Forum: General
- Topic: Stuck with local variables
- Replies: 24
- Views: 15141
Re: Stuck with local variables
Ok, so the problem is not 'how does it work', but more 'why do it this way'? So I recently made a simple eventhandler module while toying with Löve and Lua, somewhat simplified it looks like: --main.lua local EventHandler = require('EventHandler') local function printkey(key) print(key) end EventHan...
- Tue Dec 31, 2013 1:28 am
- Forum: General
- Topic: Stuck with local variables
- Replies: 24
- Views: 15141
Re: Stuck with local variables
The reason for not using global variables is not for performance reasons. It has more to do with keeping sane as you project grows larger. When everything is in the global scope you risk overwriting some of you earlier code by accident. If you called something 'x' somewhere in the code, you cannot u...