lua-users home
lua-l archive

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

>function test()
>local test_one, test_two, test_three;
>test_one = 1;
>test_two = 2;
>test_tree = 3;
>Notice the misspelling of "test_three" as "test_tree". THIS is what
>we are trying to prevent. In lua, not only do you not notice at compile,
>you don't even notice at RUNTIME! Not unless you happen to make a global
>called "test_tree", or you happen to print the global variables or

I've run into these problems as well.

>global test_tree;

Here's another solution, no globals - actually only one global table named
'global' or 'lobby' or something. This would also make Lua more consistant
and eliminate the need for all the 'global' APIs.

So when you wanted to set a global, would would do:

global.mySlot = "blah"

Another plus is that you would no longer have to declare local variables.
Any variable that doesn't begin with self or global can be assumed local.

What do you guys think?