lua-users home
lua-l archive

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


On Thu, Jul 5, 2018 at 2:28 AM Andrew Starks <andrew@starksfam.org> wrote:

> I think it’s ignorant to start off with statements like, “global by default is bad...” Better to come with your hat in your hand and ask, “Why?” first. 

That sounds as if this discussion had started just yesterday.

Well, it did not, and even the designers of the language admit that "global-by-default" might be a problem.

Roberto, 3 Oct 2006:

Local by default is wrong. Maybe global by default is also wrong (as
David just wrote), but the solution is not local by default.

http://lua-users.org/lists/lua-l/2006-10/msg00056.html

Roberto, 11 Jul 2010:

For me this issue has been settled a long time ago. The problem
in "anything-by-default" is not the choice of "anything", but the
"by-default".

[...]

I still think the main problem is non-intended assignment to globals,
which creates hard-to-find bugs. The simple policy of requiring a global
declaration to assign to globals would force programmers to consider
whether they really want a global variable.

http://lua-users.org/lists/lua-l/2010-07/msg00288.html

I am not even quoting much older messages from Roberto which discuss that a "next version" of Lua would have the global keyword. Clearly the problem of "global-by-default" is a problem that has a long history.

Cheers,
V.