lua-users home
lua-l archive

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

2011/10/16 Sebastien Lai <>:
> On Sun, Oct 16, 2011 at 3:40 AM, David Manura <> wrote:
>> I believe it's preferred to utilize package.preload rather than
>> override require.
> I've been trying to insert package.preloade[<modulename>] = <etc> in
> different ways, but it did not quite work for me.

Here is a simple working example :

package.preload.a = function(name)
    return {
        _NAME = name,
        f = print,

local b = require 'a'


What may not be clear is that preload must not contain the modules
themselves, but rather loader functions (that is, the functions that
will actually create the module, for example the body of a module