lua-users home
lua-l archive

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

On 09/10/2011 23:12, Sebastien Lai wrote:
Funny you should say that; Infact, one of the  reasons I wrote this
proposal is because both 'arg' and '_VERBOSE' are way too often
unknowingly overwritten, because neither '_VERSION' nor 'arg' are in
any way especially marked.

Having these tiny little wee tidbits covered up neatly in a sweet
little 'sys' namespace gets around such problems, and I would not
believe you if you told me you wouldn't think so as well.

"As a convention, names starting with an underscore followed by uppercase letters (such as _VERSION) are reserved for internal global variables used by Lua."

A brittle convention, since it isn't enforced by the language, but if you follow this convention, there is little risk of overwriting them. arg is the exception to this rule, but it lives only in the command line interpreter, not in the language itself. And in general, it is parsed at the start of a script, and no longer used later.

There are still a number of functions living in the global namespace, but I am happy to be able to type print() instead of System.out.print(), for example... :-)

Philippe Lhoste
--  (near) Paris -- France
--  --  --  --  --  --  --  --  --  --  --  --  --  --