[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Globals (more ruminations)
- From: Alexander Gladysh <agladysh@...>
- Date: Mon, 12 Jul 2010 03:56:49 +0400
>> 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.
> One possible downside of this is that this very simple Lua program:
> a = "Hello World"
> global a = "Hello World"
> (or "local a..."). ÂDoes this make Lua harder to learn?
While I really like mandatory global keyword, I'd also want
arbitraryName = "Hello World"
to work for some chunks with custom environments (i.e. config files).
It is not good to force config file authors to write
global NO, THANKS
at the start of file.
(Furthermore, they probably should have no say on the subject.)
Enabling global keyword by using it is not good either. (Also, too
obscure for my taste...)
Perhaps it should be an argument to the load*() function?