[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: modules, require, magic
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 20 Oct 2011 15:03:01 -0200
> > Moreover,
> > a modified 'load' function forces everyone to live with its magic.
>
> Not necessarily; Fabio's original loader did this but loader5
> restricted the magic to the users of module().
Maybe I am missing something, but I got the impression that, with
loader5 (as posted to the list), I get an empty environment if I do not
call 'module'.
local function loader(name, modpath)
local mod, env = {}, {}
env.module = function (name) ... -- not called
...
local ret = assert(load(source, modpath, 'bt', env))(name)
...
end
Moreover, it seems that loader5 has some other drawbacks. (It needs to
read the whole module as a string; all accesses to globals go all the
time through function calls.)
-- Roberto
- 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