[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Cloning "preforked" Lua state
- From: Duncan Cross <duncan.cross@...>
- Date: Sun, 6 Sep 2009 18:43:02 +0100
On Sun, Sep 6, 2009 at 5:53 PM, Phoenix Sol<email@example.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:
There's also a page on the Lua Users' Wiki: