lua-users home
lua-l archive

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

Diego Nehab wrote:

I'm playing with "package.alias" so i can set up a mapping (eg. via luainit), so that require"ltn12" knows to look in socket.dll, without having to require (and load) socket.

How does that work? Is package.alias specific to RC or is it generic
enough to say: Hey, the entrypoint for package "foo" is actually in the
library of package "bar".
That is true for C and RC functions.
Does that even make sense? It would for C, but
not for Lua.
I agree, it makes no sense for Lua.
There may be a case for different lua search strategies, but I'm not making it here.

In my implementation, package.alias is only used if the cRoot and RC loaders cannot find a package; in that case it effectively re-tries cRoot and RC with as the filename, again using cpath. Apart from anything else, it allows me to rename dll's that have name clashes with other windows software :

I have played games with the preload table, but to work in all cases (eg require a.b.c), the preload table needs to be filled in for all sub-modules. I am trying out the alias approach (which can still be an add-on loader) so that package.alias.mime=socket will resolve correctly for require"", without needing a whole slew of entries.


Perhaps findfile should be exported by the package table? Lua Authors?
I actually suggested this some time ago, off-line I believe.
That would save me replicating it, and make add-on loaders easier to implement.