lua-users home
lua-l archive

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


I can't say whether you're more interested in the behavior of module() or just looking for a solution to your problem, but in case it's the latter, since modules and functions are both chunks you can just wrap each module in an anonymous function (if I'm not mistaken). You can emulate nested modules as well:

  -- fruit.lua
  local modname = ...

  (function()
    module(modname .. '.banana', package.seeall)
    -- rest of fruit/banana.lua
  end)()

  (function()
    module(modname .. '.mango', package.seeall)
    -- rest of fruit/mango.lua
  end)()

  -- back in initial environment of fruit.lua

Hope this helps,

Peter Odding