lua-users home
lua-l archive

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

On Sun, Oct 16, 2011 at 4:39 PM, Eduardo Ochs <> wrote:
> In my opinion the two worst functions in Lua 5.1 are "require" and
> "module". They contain too much magic, and - in my opinion again -
> their implementation details are somewhat arbitrary.

require() is quite good, it does a few things more than strictly
necessary, but that allows you some flexibility in how your modules
are defined but still can be require()ed

module(), on the other hand, is the one polluting the global
namespace, and also having to meddle around with the local

that's why when i saw that it was going to be deprecated, i simply switched to:

local Modulename = {}

.... populate Modulename

return Modulename

and it works perfectly well for my needs.  when I want a slightly more
OO-style, i might add a metatable to the module table, that's just a
couple lines extra. nothing to write home about.

module() is gone, the replacement is far simpler, the structure is
unchanged.  sounds good to me, but a very trivial adjustment.

I really don't get why to keep discussing about it.