lua-users home
lua-l archive

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

2009/12/3 Javier Guerra <>:
> 2009/12/3 Ignacio Burgueño <>:
>> So far, so good. The problem I have is that I need to add a C function to
>> Foo.Bar and I can't find a good way to do that.
> my first idea would be to put it in Foo, using a discouraging name
> (something like Foo.__to_be_defined__).  in the Bar code you can use
> it, or maybe just give it a better name under Bar's namespace

Another solution is to create a third module called Foo.Bar.core,
implemented in C. Within Foo.Bar, you can then write :

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

Thanks to the "all-in-one" loader, you can put Foo.Bar.core
(luaopen_Foo_Bar_core) in Foo.dll. The C code will be loaded in memory
with the Foo module, but it won't be loaded into the Lua interpreter
until you require Foo.Bar.core.