lua-users home
lua-l archive

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


On Fri, Jul 6, 2012 at 6:17 PM, Andres Perera <andres.p@zoho.com> wrote:
> does require() hash the pathname, inode? what's the criteria for
> making an index to the cache?

Nothing so clever ;)  Lua does not know anything about directories, so
e.g on a Unix machine you will have a module path like this:

./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua

The matching is done by patterns separated by semicolons. So require
'foo' results in these candidates, after replacing ?

./foo.lua
/usr/local/share/lua/5.1/foo.lua
/usr/local/share/lua/5.1/foo/init.lua

If we had a module like 'baggins.frodo', then the period is converted
to a slash first before searching.

Thereafter, the module name 'foo' or 'baggins.frodo' is the index
(look at the table packages.loaded)

steve d.