lua-users home
lua-l archive

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


> > 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