lua-users home
lua-l archive

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



On Mar 28, 2012 5:53 AM, "codemonkey Monkey" <thecodemonkey@rocketmail.com> wrote:
>
> > although this might work, I strongly recommend you rethink you design in Lua.  USE LUA IN THE WAY LUA IS.
>
> Well, Lua the "the way it is", with no changes, means every variable written by any script will go into the same namespace, _G, and that's a pretty error prone thing.  There will be conflicts between names used by different scripts and objects, and it'll just be unworkable.

"Prefixing" works pretty nicely, same as using the "local" keyword to create variables. This is much like in C. I have maintained quite a bit of Lua code and globals weren't a problem. If some code is doing something wrong regarding globals, you can use metatables to find the cause without much of a problem.
Don't try to make your engine bulletproof for people who don't understand what they do. They'll just break it differently and the more you try to prevent them from doing it, the more it'll hurt in the end. The earlier they are confronted with their own code that doesn't work, the better. That's my opinion at least.

Cheers,
Eike