lua-users home
lua-l archive

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


On 8/07/2010, at 6:04 PM, Vaughan McAlley wrote:

> On 8 July 2010 12:44, RJ Russell <russellsprouts2@gmail.com> wrote:
>> add one new keyword, global, and keep the local keyword.
>> Everything is local by default, not overriding any already existing locals, but the global keyword makes a global, and the local keyword creates a new one.
>> 
>> a=1 --auto local
>> do
>>   a=2 --same one
>> end
>> 
>> (Though 5.3work3 with _ENV changes a lot.)
>> 
> 
> I think using the local keyword makes it easier to spot a variable‘s
> scope when scanning code. It would be less obvious whether a variable
> is a local or an upvalue (or a global declared elsewhere).
> 
> Vaughan

But there's nothing stopping you using "local" if you want to is there?

An alternative might be that every variable you assign to has to have an in-scope non-implicit local or global declaration.  Any reading of a variable without an in-scope declaration would have to be assumed to be global.

Geoff