lua-users home
lua-l archive

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

OK, I can see that if you are actually loading libraries written for the require system into the Lua environment from C, it will be safer to do so through the require function. However you would still not put such libraries into the preload table.

The other alternative is just to put the library loader function into the preload table. Then the library gets loaded correctly by the require function when that is executed from the Lua script. This allows you to compile the library in, but only load it into Lua if required by the scripter.

> -----Original Message-----
> From: [mailto:lua-
>] On Behalf Of Jerome Vuarand
> Sent: 03 September 2009 15:01
> To: Lua list
> Subject: Re: Wishlists and Modules (was [ANN] libmc)
> 2009/9/3 John Hind <>:
> > But why bother putting it in the preload table if you then
> immediately load it
> > using C code? The idea of the preload table is so you can have C
> libraries compiled into
> > the runtime but which only get loaded into the Lua environment if
> called for by
> > the script. If you load it right off, you should load it like any of
> the standard
> > libraries i.e. by just executing its loader function.
> Loaders of the standard libraries are designed to be just executed.
> Modules that are designed to be loaded through require may rely on the
> extra features of require to work properly (ie. setting
> package.loaded[modname] to the return value of the loader).