lua-users home
lua-l archive

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

> As for my own idea lots of people will hate:
> - introduce global as a keyword to make a variable global
> - leave the current defaults alone
> - introduce a new mode where variables must be explicitely declared before
> being used
> - make the new mode swtichable either by a compile-time flag or a command
> line parameter

That is similar to what we are thinking. A global keyword to declare global 
variables, and a mode that demand explicit declaration of all variables 
that get *assigned* (not used; otherwise we sould have to declare every 
global function that we call... Or should we?). (Maybe the "global" 
declaration itself may work also as a switch for strict declaration mode.) 

For modules/libraries, such global declaration at the beginning of the
file would list all "things" created by that module.

This solution is simple to explain (both formally and informally), is 
simple to implement (we don't need to go until the end of a function to 
know whether a variable is local), is compatible with previous versions 
(apart from the new keyword), and solves the problem of avoiding nasty

-- Roberto