lua-users home
lua-l archive

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


Peter Loveday wrote:
> I suppose for me the ideal would be an explicit global declaration
> and local-by-default behaviour.
> 
> Love, Light and Peace,
> - Peter Loveday

This is much like it is done in PHP, and I also would prefer 
something like this. Variables within function scope should
override variables within global scope. We don't even need a 
seperate keyword, as long as we have a table like 'globals' or 
such in which all global variables are kept.

So for example:

bar = 10;

fuction foo()
bar = 5; -- this bar is local to foo()
print(bar);
bar = globals.bar; 
-- Get your global bar like this.
-- It is ugly, but global variables are 
-- usually a bad idea anyway.
print(bar):   
end;

Should then print: 
5
10

On top of that, a 'global x' keyword could be allowed as
syntactical sugar for 'x = globals.x'.




-- 
"No one knows true heroes, for they speak not of their greatness." -- 
Daniel Remar.
Björn De Meyer 
bjorn.demeyer@pandora.be