[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Conceptual problem with module
- From: Mike Pall <mikelu-0604@...>
- Date: Tue, 25 Apr 2006 11:39:51 +0200
Hi,
Chris Marrin wrote:
> Why do modules get put into the global namespace? And why doesn't module
> return a reference? Am I missing an easier way here?
Well, then why bother using it? You are better off with:
local _M = {}
local function helper() ... end -- not part of the module API
function _M.foo() ... end
function _M.bar() ... end
return _M
The lost convenience of using global assignment for module
function definitions shouldn't worry you. In fact now you have
unrestricted access to all globals (you'd need package.seeall for
module()). It also provides a clear indication which functions
are part of the module API.
Bye,
Mike