lua-users home
lua-l archive

Requiring relative modules

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


Hi. I'd like to know if the following is doable with Lua 5.1.3
I have a directory in my package.path, say c:\packages, like this:
C:\packages\?.lua;C:\packages\?\init.lua;
and the following directory structure (best seen with a fixed width font):
c:\packages
 |
 *-- apps
 |
 *-- login
 |- init.lua
 |- validator.lua
so, require"apps.login" loads init.lua
In init.lua, the module definition is
module(...)
since I may move the package 'login' to a different place (I cannot assume module("apps.login") will be valid)
Although I can require 'validator.lua' using
require( select(1, ...) .. ".validator" )
is there a way to do that by default?
Regards,
Ignacio Burgueño

AltStyle によって変換されたページ (->オリジナル) /