lua-users home
lua-l archive

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

Am 04.02.2017 um 12:44 schröbte Dirk Laurie:
[Summary of thread: Some people would like Lua to add the directory
of the currently running main script automatically to the package path.
OP admits that other ways to achieve that effect exist but claims that
no good reason for Lua not to do so has been advanced. Several
posters have been stressing the other ways, but Russ keeps forcing
the issu back to "why not?" and is not impressed by the technical
arguments advanced so far.]

I think loading a module relative to the last loaded Lua module on the call stack (like penlight's `require_here`) would make a good candidate for a new searcher (standard or via LuaRocks, I don't care). It doesn't have to be perfect, just good enough for some deployments. Since it already can be done in C or in Lua+debug API, maybe we should implement a proof of concept, and give the Lua community something to play around with.

Anyway, I also wanted to mention a new rock that appeared recently on, and might be of interest: lua-whereami[1], which gives you the path to the Lua executable, so you can at least require modules relative to the Lua executable on non-Windows machines, too ...