lua-users home
lua-l archive

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


It was thus said that the Great Philipp Janda once stated:
> On 21.10.2011 06:10, Sean Conner wrote:
> >
> >[...]
> >   Code wanting to be a module would do:
> >
> >	----[ sample.lua ]---------
> >
> >	local string = _REQUIRE("string")
> >	_MODULE()
> >	function split(s,delim) ... end
> >	function wrap(s,margin) ... end
> >	function trim(s) ...end
> 
> You forgot 'return _ENV'! Since _MODULE does not get the module name, it 
> cannot pass the exported definitions via 'package.loaded[ name ]'. So 
> you must pass the exported definitions via 'return'.
> 
> If you add 'return _ENV', _MODULE() becomes '_ENV = {}'.

  I was trying to come up with a way around that.  I'm still thinking.

  -spc