lua-users home
lua-l archive

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


Hi,

> Does one really want the exported namespace for a module to inherit the
> globals?

I believe the original idea  was to have globals defined after the call
to module("foo") fall in the namespace for "foo" instead of in _G. This
is something I really like and I would fight to keep. :)

As colateral damage, once module("foo") replaces the environment of the
caller, no globals are visible anymore. To remedy this, the __index
metamethod of the namespace itself was made to point to the original _G.

Since you can capture all needed globals before calling module("foo"),
perhaps this fix should be removed altogether. I prefer the complete
removal to a more complex solution (Lua philosophy...).

We can also leave it as it is because one can remove the __index
metamethod from the namespace after calling module("foo").

Regards,
Diego.