lua-users home
lua-l archive

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


	Hi Jerome

> An example may be clearer. Suppose that you have a loader that get Lua
> rocks from the net:
> 
> -- Install the loader
> require("rocks.loaders.http")
> 
> -- Get some modules from the official rocks website (fictionnal url)
> require("lxp", "http://rocks.lua.org/";)
> require("pdf", "http://rocks.lua.org/";)
> 
> -- Get some modules from your corporate intranet quality assurance site
> require("syslog", "http://qa/";)
> 
> And from here you can use modules lxp, pdf, and syslog as normal
> modules. There are other solutions to the problem, I could for example
> embed the url in the module name like require("org.lua.rocks.lxp"), or
> as methods of the loader module, but that can be done to modify normal
> modules too. My point is that extra parameters to require may be used to
> configure how module are loaded rather than how modules will work.
	Why don't you use a `package.urlpaths' to configure that?

package.urlpaths = {
	lxp = "http://rocks.lua.org/";,
	pdf = "http://rocks.lua.org/";,
}

	You already could implement a loader like that, don't you?

	In fact, I think my proposal is not good enough, but I don't
have a better one.  Maybe someone else has :-)

	Regards,
		Tomás