[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: require and loops
- From: RLake@...
- Date: Mon, 20 Oct 2003 14:50:49 -0500
>> The "main" of a module may use functions from another required module.
> I suppose I have a problem with modules having a "main". Only programs
> should have a main.
The main of a module should test the module, I would say.
-- MySnazzyModule
-- Tries to be compatible with various module mechanisms
-- (_init)
require "import"
local midi = import "MyMidiVersion2"
-- (end _init)
local function pif(tab)
function tab.sing(x) end
function tab.dance(y) end
return tab
end
if _REQUIREDNAME then
getenv()[_REQUIREDNAME] = pif {}
return true
elseif _LTN11 then
return pif
end
local Snazzy = pif {}
Snazzy.sing "Bésame"
Snazzy.dance "tango"
-- obviously not enough tests, but
print "Test of all-singing, all-dancing module succeeded"
---------------------------
But I think he was talking about the part labelled (_init) above.
Rici