lua-users home
lua-l archive

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


On Fri, 4 Jun 1999 rw20@cornell.edu wrote:

> The two options I thought of are
> 1. just make variable assignment default to local inside functions
> 2. require declaration of all globals and locals inside functions
> 
> Both options break old code though.  So the would need to be a 
> variable_mode or a new "function" keyword.  The second option kind of 
> goes against the "easy to write code" model of lua.  Option one coupled 
> with requiring all locals to be declared (as it is now) is the best solution.
> Assigning to something not declared as local or as an arguement would be 
> an error.

Here's another possibility:  if you created a getglobal and setglobal
tag that worked on everything, you could implement something yourself.
(Personally, I would just disable global assignment once all the functions
are defined.)  

I'm not sure what the speed penalty would be for that.  Obviously, since I
don't assign to globals very often, a setglobal tag wouldn't slow things
down much.  getglobal might be too slow, though, since it would be used on
all function calls.  I could live with just a setglobal tag, though. 

F