lua-users home
lua-l archive

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


On 16/07/2010, at 8:20 AM, Roberto Ierusalimschy wrote:

>> Does this mean that if we wish to have global checking for variables
>> in a module, we'll have to go "global function" for the rest of the
>> module to get module functions?  From the first global on function
>> mymodulefunction(...) will be an error right?
> 
> Right.

So I was going to suggest that "function(...)" becomes sugar for "global function(...)" but doesn't turn on global checking for its scope).  It's based on the unsubstantiated guess that "a = 1" is more likely to be intended to be a local than "function f(...)", but now I don't think it's a good idea.

If you put "global CHECK" at the top of your file, then with this, the advantage is you won't have to type "global" at the start of your file-level functions.  The problem is that you won't get global checking for functions defined inside functions and other scopes.

I guess what's bugging me is that the global proposal doesn't completely dominate strict.lua: strict.lua checks assignments to globals in scopes other than the top level without any changes to the code.  The global proposal offers static checking and can check the top level, but at the cost of more changes to the code.

Cheers,
Geoff