lua-users home
lua-l archive

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

On Feb 12, 2013, at 1:17 PM, Peter Slížik <> wrote:

Okay, here's the new thread I announced a while ago...
Lua-users wiki cites Roberto's words:
"Local by default is wrong. Maybe global by default is also wrong, [but] the solution is not local by default."
Could anybody who understands Lua innards elaborate?

Imagine Lua did local-by-default and you write a script with this line:
foo = true
You assume that "foo" is local, and it works when you test it.  Unbeknownst to you, in deployed use, some other script loaded in the same Lua state had created a global variable "foo" for some other purpose.  As far as Lua can tell, your "foo" is referring to the global one.  You've now broken their script, or they'll later break yours.