lua-users home
lua-l archive

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


 > > Most people only seem to touch the package model using require,
 > > module, and package.path/cpath, and the whole aspect of loaders seem
 > > to get lost, leading lots of people to regard overriding require()
 > > as the only means of adjusting it's behavior.  So, I see it fit to
 > > provide additional documentation regarding this, and also perhaps a
 > > page on the wiki which further explores it's uses.
 > 
 > The reason we never wrote this documentation is that we planned to
 > change the name of package.loaders. We have a problem that "loader"
 > means two different things: a function to load a module, and a function
 > to searh for loaders. The first use is somewhat fixed by lua_load, and
 > the second by package.loaders.

Looking at the source, it does seem that if I want to provide some
sort of precompiled or preloaded modules, I could simply write my own
specialized package loader and then do

  table.insert(package.loaders, 1, myloader)

where 'myloader' returns a function on successful load, string on
error, and nil otherwise.  Then everything would be great, right? 


Norman