lua-users home
lua-l archive

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


I'm looking for a straightforward way to define what a module exports -- other than setting all the rest global. Ideally, this would be something like:

-- module mod
__export = {CONST=CONST, config=start_config, test=mod_test.test, do=safe_do}

CONST = 3.14
start_config = {...}
do = function(...) ... end
safe_do = function(...) ... do(...) ... end

Then, as you guess, requiring "mod" would export only the content of __export.
Is there method analog to this?


At a more general level, I'm thinking at predefined (table) names for execution, export, & possibly test. These are, I guess, three manners of accessing lua code files whith distinct intents. "module" could hold settings about what/how local objects should be exported, "program" could hold init and run code (similar to main in other languages). Test could hold a testsuite, indeed (but there should then be a way to load a code file in test mode).


la vita e estrany