[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: modules, require, magic
- From: Pierre Chapuis <catwell@...>
- Date: Mon, 17 Oct 2011 23:39:51 +0200
On Mon, 17 Oct 2011 19:11:38 -0200, Luiz Henrique de Figueiredo wrote:
local M={}
M.version="1.0.2"
function M.f() ... end
...
return M
There is no need for a module function and no need for syntax either.
No one needs to know about _ENV for that only for complicated things
like avoiding writing "M." (probably not a good idea as it serves as
documentation of what is exported).
I use an alternative construction that does the same thing in the end:
local f = function() ... end
return {
version = "1.0.2",
f = f,
}
I also think modules shouldn't modify the global namespace.
This solution doesn't allow concatenation of module files but this is
a small price to pay for a simple, understandable module mechanism.
--
Pierre Chapuis
- References:
- modules, require, magic, Eduardo Ochs
- Re: modules, require, magic, Javier Guerra Giraldez
- Re: modules, require, magic, Petite Abeille
- Re: modules, require, magic, Sam Roberts
- Re: modules, require, magic, Hisham
- Re: modules, require, magic, Luiz Henrique de Figueiredo