lua-users home
lua-l archive

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


It was thus said that the Great Dibyendu Majumdar once stated:
> On 2 February 2018 at 22:18, Sean Conner <sean@conman.org> wrote:
> > It was thus said that the Great Dibyendu Majumdar once stated:
> >> On 2 February 2018 at 22:00, Sean Conner <sean@conman.org> wrote:
> >>
> >> >   Lua modules written in Lua can be renamed easily---just change the name of
> >> > the file [1].  Modules written in C can't be renamed without a code change
> >> > due to possible linking restrictions [2]---Lua looks for
> >> > "luaopen_modulename" when loading a C-based module.
> >>
> >> I was thinking that require should allow an optional module name -
> >> i.e. lookup as now, but use the module name (if given) when saving the
> >> reference. That way, the name of the module inside Lua becomes
> >> independent of how the module was resolved.
> >
> >   Example?  My own syslog module is in C, and the exported symbol is
> >
> >         luaopen_org_conman_syslog
> >
> 
> something like:
> 
> local syslog = require ('org.conman.syslog', 'conman.syslog')
> 
> So that Lua uses 'conman.syslog' to register the library in package.preload.
> 
> I haven't really thought this through but it should convey the idea.
> 
> Of course this is still problematic because someone has to require it
> with the desired name - then other references can use 'conman.syslog'.
> So it probably doesn't work.

  Related is this thread, from 2013:

	http://lua-users.org/lists/lua-l/2013-06/msg00464.html

  -spc