lua-users home
lua-l archive

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


Etan S. C. Reisner wrote:
> What aspects of the module system are you trying to make your C
> module play nicely with? I've written a number of C modules, called
> module() from none of them and they work just fine when being
> require():ed.   
> 
> I'd have thought you might have been trying to get the 'only
> functions I ask for in the module environment' bit but the
> package.seeall goes against that.  
> 
> So what exactly are you trying to get module() to do for you here?

Basically everything it does for the Lua modules. Setting _M, _PACKAGE,
_NAME, setting the global. But more important I'd like the binary module
to still work well on environments where module has been replaced with
another implementation.

For the moment, if some particular Lua users replace "module" with a
custom version more adapted to its environment (for example in some
project I'd like "module" not to set the global tables, only register
the module in package.loaded), Lua modules will still work with that
environment, but binary modules may fail to. Calling "module" will
ensure that the code provided by the user get called, the code necessary
to adapt the module to the new environment "from the inside".