lua-users home
lua-l archive

[proposal] Libary changes

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


Before I start: This proposal might or might not be somewhat biased on
my previous experience with modular programming languages like python
and co.
What I bothered me most about Lua is the way global
"more-or-less-constant" variables are declared - meaning especially
_G, _VERSION, and the variable "arg" containing the arguments vector
passed to 'main' in the native environment (usually C and/or C++, but
also Java, CSharp, etc).
What I propose is to create a new module named "sys", that will
respectively contain that data instead, like:
 sys.argv instead of arg
 sys.globals instead of _G
 sys.version instead of _VERSION
In my opinion, that would make more readable, and possibly avoid
ambigious re-declaration of 'arg' (that unfortunately happened to me
before, when I learned Lua, for example).
Having a 'sys' module might also make it more interesting to share
some more lowlevel information acquirable through the C
standardlibrary with Lua, instead of polluting the global namespace.
And, similar to 'os' and 'io', this module should be part of the
global namespace.
What do you guys think?

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