> 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.
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
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.
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.