[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: modules, require, magic
- From: James Graves <james.c.graves.jr@...>
- Date: Fri, 21 Oct 2011 07:22:28 -0500
"Hisham" <hisham.hm@gmail.com> wrote:
> With the module() + package.seebase variation suggested at [1] I think
> the only remaining drawback would be that all accesses to globals go
> all the time through function calls when using package.seebase.
Can we just do this instead for seebase?
function package.seebase(mod)
local env = {}
setmetatable(env,
{ __index = setmetatable(mod, {__index = lua_libs}),
__newindex = mod })
return env
end
More indirection, but no function call. Since we're already copying
package.loaded._G can we just lazily cache those in the mod table too?
-------------------------------
Other people have been complaining about the module discussion on the
list recently, but I think it has been productive too.
I think we may be close to a solution that will have broad approval.
James Graves
- References:
- Re: modules, require, magic, Petite Abeille
- Re: modules, require, magic, Sam Roberts
- Re: modules, require, magic, David Manura
- Re: modules, require, magic, Hisham
- Re: modules, require, magic, Roberto Ierusalimschy
- Re: modules, require, magic, Fabio Mascarenhas
- Re: modules, require, magic, Roberto Ierusalimschy
- Re: modules, require, magic, Hisham
- Re: modules, require, magic, Roberto Ierusalimschy
- Re: modules, require, magic, Hisham
- Re: modules, require, magic, Roberto Ierusalimschy
- Re: modules, require, magic, Hisham