lua-users home
lua-l archive

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


Roberto Ierusalimschy wrote:
>> 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.  
> 
> But it seems now is too late for that...

In my gem which precisely talks about that aspect of the module system,
and I had to face that ambiguity. I decided to keep the 'loader' name
for the package.loaders, and to name the module init function (the
module chunk in Lua, or luaopen_ function in C) the module's 'entry
point'. I explicitly stated that in a note in the gem text.

Maybe you can have a look at the preliminary gem text that I submitted
to see if it sounds right, or if the other alternative is better (that
is renaming package.loaders and keeping the 'loader' concept for the
module provided init function).