lua-users home
lua-l archive

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

>> 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 end
  return tab

  getenv()[_REQUIREDNAME] = pif {} 
  return true
 elseif _LTN11 then
  return pif

local Snazzy = pif {}
Snazzy.sing "Bésame" "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.