lua-users home
lua-l archive

Re: global

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


> [It] forces programmers to know the name of all global variables and 
> avoid them, to prevent them from being changed unadvertently. I wonder 
> how the proposed global in ... statement brings adequate solace for 
> that problem. 
The idea is that, optionally, you can have a declaration like
 global in nil
or
 global in {}
Then, any access to a non-declared variable wouldn't affect a global
variable (in the first option it would be an error, in the second it
would access a "static" variable). With proper support, we could have
other options, like
 global in ReadOnly(globals())
where you could only read undeclared global variables, but any write
would trigger an error.
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /