lua-users home
lua-l archive

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

On Wed, May 11, 2016 at 9:26 AM, Viacheslav Usov <> wrote:
> On Tue, May 10, 2016 at 7:00 PM, Sean Conner <> wrote:
>>   I think he wants something like:
>>         global x        -- define a global x
>>         function foo(a,b)
>>           local c       -- define a local variable
>>           c = a * b + y -- compile time error---y not defined
>>         end
> I am not exactly sure. The more I think about it, the more convinced I am
> that, in principle, it is enough for the explicit mode to remove the current
> syntactic sugar that converts anything not defined as a local into a global
> table lookup. This will eliminate the silent promotion of mistyped locals
> into globals, and the need to type the ugly _ENV will always be a reminder
> for users that globals are not exactly cheap.
> But I am not going to insist on that.
> Cheers,
> V.


you can use luacheck as a library and filter warnings to keep only
warnings about global variables. For example, you don't want "unused
variable" warning, but want only "using global" warnings - it is easy
to implement.

By the way, without any globals, how can one use normal globals like
"print", "math" etc? Always declaring them is annoying.


Best regards,
Boris Nagaev