lua-users home
lua-l archive

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


On 18 October 2011 19:50, Petite Abeille <petite.abeille@gmail.com> wrote:
> Ought to stay to provide a standard implementation for modules.

I admit I truly do not understand why you insist on Lua lacking a
"standard implementation for modules" without module() (pun intended).

What is wrong with having modules defined as Luiz and Mike (and others) suggest:

local _M = {}
-- whatever, put stuff that belongs to the module in _M
return _M

It's fast(er), easy, clear, 1 extra line needed, exported stuff is
evident. Everybody can easily load your module (library) with:
local lib = require "lib"

I believe that's a reasonable "standard". I hope you do not qualify
the two lines involving _M as "reinventing the wheel" :-)

It's easy to add lazily loaded "sub modules" in case one is interested.

KR