lua-users home
lua-l archive

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


> > Is it this table supported? Is it ok to modify it (from the code that 
> > embeds LUA) to introduce generic loaders that should be executed before 
> > the existing ones?
> 
> I have done this in my system to use my own file lookup logic and to 
> load non-lua files using require. It works like a champ.

As you mentioned that, we should say that there is a small modification
here for 5.1 final (with no incompatibilites!). When a loader fails,
it can return a string instead of nil. That string is concatenated to
the error message from 'require' if it cannot find the module.  For
instance, the default loaders create an error message like this:

> require 'a'
stdin:1: module 'a' not found:
        no field package.preload['a']
        no file 'a.lua'
        no file '/home/roberto/sys/lua/a.lua'
        no file '/usr/local/lua/lib/a.lua'
        no file './a.so'
        no file '/home/roberto/sys/lua/a.so'
        no file '/usr/local/lua/lib/a.so'

(The 'no field' line was returned by the preloader,
the next three lines by the Lua loader, and the last three lines
by the C loader.)

If the loader returns nil (or nothing), nothing is added.

We felt that this kind of error can be quite confusing, and the more
information the better.

-- Roberto