lua-users home
lua-l archive

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


> And that code can use any style... e.g. lpeg's re uses _ENV
> and luasocket still uses module().

LPeg's re does not use _ENV. It explicitly builds its table and returns it.

Anyway, can't you hanlde all them the same way, by packing each module
inside a function, more or less like this?

do    -- module A "inlined" here
  local _ENV = _ENV
  local function mod (...)
    <<module original source code>>
  end
  package.preload.A = mod
end

do    -- module B "inlined" here
  ...
end

-- main code
local x = require'A'
  ...

-- Roberto