[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: global keyword instead of local
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Sat, 26 Aug 2000 21:15:48 -0300
>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
Not very hard. But the main point is, do you really want to do this?
This has been discussed before; check the lua-l archives.
The main point is the following:
If all variables are local by default, then you have to declare all functions
as global. For instance:
while 1 do
if s==nil then return end
Also, as Russ Webb noted, you can set tag methods do warn about unintentional
uses of globals (of course, this will only happen at run time).
Another possibility is to run luac -l and see what globals are used.
>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.
Would they prefer to write global declarations for all functions??