lua-users home
lua-l archive

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


On Sun, Sep 6, 2009 at 5:53 PM, Phoenix Sol<phoenix@burninglabs.com> wrote:
>> All threads would use the same ***instance*** of all globals, so if you
>> save something in a global variable in one thread, it affects all threads.
>> This is a very undesirable trait in server threads.  If you forget to make a
>> variable local and write to it you have a problem.
>
> I hate to say it, but I think that this is a flaw with Lua. Most of the time
> you want to declare locals, and that should be the default.

Unfortunately, it turns out local-by-default would cause more problems
than it would solve, due to Lua's scoping. Mike Pall's post about it
here is probably the best summary:

http://lua-users.org/lists/lua-l/2005-08/msg00139.html

There's also a page on the Lua Users' Wiki:

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

-Duncan