lua-users home
lua-l archive

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


2007/2/25, Norman Ramsey <nr@eecs.harvard.edu>:
Thanks; I thought some scurvy submodule trick might be the way to go...

My one misgiving is that the name of the library is built in.
I think I'd prefer to let the C code wind up in the core submodule and
then write

   for k, v in pairs(_M.core) do _M[k] = v end

Does someone who understands modules better than I do think this would work?

Yes, you can do that. That's the way I usually expose core functions
in my hybrid modules. You can also create a list of functions to
export if some of them are meant to be private:

module(..., package.seeall)
local core = require(.....".core")
for _,funcname in pairs(core.api) do _M[funcname] = core[funcname] end

where core.api is a table.