[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: One more item to the collection of Lua hate-speech
- From: Geoff Leyland <geoff_leyland@...>
- Date: Thu, 8 Jul 2010 15:20:43 +1200
On 8/07/2010, at 2:44 PM, RJ Russell wrote:
> Here's one way to avoid the issue in code like this and get rid of the globals problem.
> a=1 --auto local
> do
> a=2
> --is this a new global?
> end
> print(a) --what is it?
>
> 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
I think I like this. You might want "function f() ... end" to be by default global or you likely be typing "global function" most of the time. Any access of (not assignment to) a name that didn't have an in-scope local or global declaration would have to be assumed to be a global, otherwise "print" wouldn't work.
Geoff
- References:
- One more item to the collection of Lua hate-speech, Alexander Gladysh
- Re: One more item to the collection of Lua hate-speech, Luiz Henrique de Figueiredo
- Re: One more item to the collection of Lua hate-speech, Petite Abeille
- Re: One more item to the collection of Lua hate-speech, Wim Couwenberg
- Re: One more item to the collection of Lua hate-speech, Mark Hamburg
- Re: One more item to the collection of Lua hate-speech, Mark Hamburg
- Re: One more item to the collection of Lua hate-speech, Roberto Ierusalimschy
- Re: One more item to the collection of Lua hate-speech, Geoff Leyland
- Re: One more item to the collection of Lua hate-speech, Roberto Ierusalimschy
- Re: One more item to the collection of Lua hate-speech, RJ Russell