lua-users home
lua-l archive

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


> Whilst this is a pain I think I would rather live with pain than see the
> current Lua work6 require() messed up. work6 require is clean and tight.

So here goes another proposal to solve the specific problem of "whole
package in one DLL" that tries to change as little as possible from
work6 require:

- add another loader after the others:
when requiring "a.b.c", it trys to find a module "a" in the C path;
if found, tries to find the function luaopen_a_b_c there and returns it.

(I assume that there is no need to pack whole *submodules* as one DLL,
so there is no need to look for a.b or anything like that.)

(Unlike the original C loader, it is not a hard error not to find the
open function there. It is simply a soft error meaning "module not found
here".)


If we really want to care for the obsessive people:

- add yet another loader after the others:
when requiring "a.b.c", it trys to find a module "ALL" in the C path;
if found, tries to find a function luaopen_a_b_c there and returns it.
(I assume that there is no need to pack whole *submodules* as one DLL,
so there is no need to look for a.b or anything like that.)

The main benefit is that those changes to do not affect the basic
behavior of require. They only add well-behaved loaders for specific
goals. No side-effects, no hidden modules being loaded, no failed
requires. They only search for the module in extra places.

-- Roberto