[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: changes in 'require'
- From: Mike Pall <mikelu-0507@...>
- Date: Fri, 8 Jul 2005 20:03:07 +0200
Hi,
Diego Nehab wrote:
> I am assuming module writers *will* call module(). I was asking if there
> is a way to avoid the global namespace polution without changing every
> package in your systeme not to use module, and without rewriting the
> module function either.
There's no way to intercept the writes to _G, because the underlying
functions use lua_rawset(). You could write a wrapper for require()
that deletes the globals after they have been set. :-)
If you're willing to patch the source, you could modify ll_module()
and luaL_module() to anchor the created namespaces at LUA_REGISTRYINDEX
instead of LUA_GLOBALSINDEX. Or maybe a sub-table of the registry.
Not pretty either.
Bye,
Mike