lua-users home
lua-l archive

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


I modified Lua to require global and local declarations once.  This was back
when lex was still used for parser generation so the code I wrote is useless
now.  Removing the requirement of the local keyword was my next goal.

Such a default to local system is much more controlled and less error prone
(I think), but is a major change to the language.

It turns out that you can redefine the setglobal tag to prevent global
creation save through some global("name", value) function call.  This does
most of what I wanted so I stopped worrying about changing the language.  Of
course you still have to use the local keyword, but that's a fairly minor
annoyance.

Russ

> From: "Martin Dvorak" <mdvorak@ninell.cz>
> Reply-To: lua-l@tecgraf.puc-rio.br
> Date: Sat, 26 Aug 2000 21:56:48 +0200
> To: Multiple recipients of list <lua-l@tecgraf.puc-rio.br>
> Subject: global keyword instead of local
> 
> Hi all,
> 
> How hard would it be to modify Lua source code
> to add "global" keyword for explicit declaration
> of global variables and make all variables local
> by default?
> 
> Current implementation of Lua uses opposite
> approach, but that approach is problematic
> for us because our scripters are not
> programmers and it seems there is no force
> which makes them remember that they always
> have to declare their variables as local.
> 
> Thanks for help,
> Martin