lua-users home
lua-l archive

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


That sounds definitely weird. How do I then tell require *where* to look for the module? So if I write "a = require 'foo'" how does does the loading mechanism know where to look for 'foo'? The default path values imply that requiring a 'foo' will try to find either a foo.lua or an foo/init.lua in a number of different places. This is also described in the package.searchers description, both by referencing package.searchpath() for Lua loader and very explicitly for the C library loader.

So if the paths are for finding loaders how do I tell where to find the modules? Does that mean I have to give the absolute path for require?

Robert

----- Original Message -----
> From: "Jerome Vuarand" <jerome.vuarand@gmail.com>
> 
> 2013/12/6 Robert Virding <robert.virding@erlang-solutions.com>:
> > Yes, it is clearer. The current sentence implies that used to FIND a loader
> > and not that it is used BY a loader. Require doesn't directly know about
> > files although it does know about an extra argument apart from the module
> > name which is passed in the call to the loader.
> 
> I think you're confusing some concepts here. The path is not used "BY
> a loader". The path is used "BY a searcher to FIND a loader". The
> loader is not aware of the path.
> 
> The loader is not the code finding or compiling the module, the loader
> is the module init function (luaopen_ in C or the module script body
> in Lua). The function finding loaders, compiling them (if necessary)
> and returning them to require is called a searcher.
> 
>