lua-users home
lua-l archive

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

It was thus said that the Great Sebastien Lai once stated:
> On Fri, Oct 7, 2011 at 3:49 PM, Luiz Henrique de Figueiredo
> <> wrote:
> >> 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
> >
> > Save the file below and you can do "lua -lsys" though arg will probably not
> > work.
> >
> Good catch. Of course, 'sys' is meant to be a 'virtual' module (quite
> frankly, I don't know if that word is fitting, I haven't felt like
> digging through the Lua source yet), so some serious changes in the
> runtime sources would probably required.

  Changes required aren't that bad actually.  _G and _VERSION are set in
base_open() (lbaselib.c, and that's the only place they appear in the C
source code) and arg is set in lua.c, so it would be rather minimal changes. 
Bigger would be existing Lua code that relies on these variables.