[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: modules, require, magic
- From: Petite Abeille <petite.abeille@...>
- Date: Wed, 19 Oct 2011 19:27:19 +0200
On Oct 19, 2011, at 7:20 PM, Hisham wrote:
> Well noted. Doing this gets us the following:
Alternatively, perhaps this can be boiled down to something along these lines:
function module( aName, ... )
local aModule = package.loaded[ aName ]
if type( aModule ) ~= 'table' then
aModule = {}
aModule._M = aModule
aModule._NAME = aName
aModule._PACKAGE = aName:sub( 1, aName:len() - ( aName:reverse():find( '.', 1, true ) or 0 ) )
package.loaded[ aName ] = aModule
for anIndex = 1, select( '#', ... ) do
select( anIndex, ... )( aModule )
end
end
return aModule
end
http://dev.alt.textdrive.com/browser/HTTP/debugx.lua#L79
- 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, David Manura
- Re: modules, require, magic, Hisham
- Re: modules, require, magic, Roberto Ierusalimschy
- Re: modules, require, magic, Fabio Mascarenhas
- Re: modules, require, magic, Roberto Ierusalimschy
- Re: modules, require, magic, Hisham