lua-users home
lua-l archive

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


> > isn't require() the one that writes the module in package.loaded?
> > [...]
> 
> It's a bit more complicated than one or the other - require() will not
> overwrite a value set into package.loaded[...] if the loader function
> sets it directly, and module(...) does just that.

Not exactly. require will not overwrite whatever is in
package.loaded[...] only if the module returns nothing (or nil).
If the module returns a value, that value will overwrite whatever
is in package.loaded.

This is the kind of complexity that we think most users do not need
to know.

-- Roberto