lua-users home
lua-l archive

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

On 19 Feb 2013, at 08:27, steve donovan wrote:

   # lib/module.lua
   return { VERSION="0.3.1" }

And no globals were harmed in the process, at the slight cost of an
extra module which just has the job of initializing the main table.
Thereafter require() ensures that it is unique.

I believe this was pretty much my solution, except I used package.preload in init.lua to define the module table instead of a separate file.

All modules return an
appropriate table, which is strongly recommended.

Is that necessarily a good idea? If a module's purpose is to modify or enhance existing modules, and it doesn't naturally produce a table, should it really return a table? In the abstracted example, what should multi.lua return?