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 Milind Gupta once stated:
> >
> >
> >   Why add the parent directory?  This just translates to
> >
> >         C:/a/b/?/d/?.lua [1]
> >
> 
> Yes it does. The c directory comes in because in luaconf the path is
> defined relative to the lua executable directory for example. so C:/a/b/c
> is the directory path of the lua executable which gets substituted when the
> lua executable is started and ../?/d/?.lua is the path that was placed
> relative to it. So package.path shows the path like that.
> 
> >
> > > Then it require("mod") searches for
> > >
> > > C:\a\b\c\..\mod\d\mod.lua  -> C:\a\b\mod\d\mod.lua
> > >
> > > This is good.
> >
> >   What is the extra directory buying you?  I fail to see the benefit of an
> > extra directory.
> >
> > > require("mod.submod") searches for
> > >
> > > C:\a\b\c\..\mod\submod\d\mod\submod.lua
> > >
> > > It would be much better I think if it searched:
> > >
> > > C:\a\b\c\..\mod\d\mod\submod.lua
> >
> >   What about a module named "org.conman.syslog"?
> >
> 
> The thought is that sub modules would reside inside the sub directories
> where the main module resides. So for org.conman.syslog, org is the main
> module and then syslog is the submodule so it should translate to:
> C:\a\b\org\d\org\conman\syslog.lua

  !!!!

  Why does everybody assume "org" is the "main" module when it's not?  It's
not "org" with "conman.syslog" as a submodule, it's "org.conman.syslog". 
The first two levels, "org.conman" just namespace my modules.

  Geeze, I might have to make "org.flummux.syslog" just to prove the point!

> This allows for example just pull the whole directory structure of many
> github projects and have them available immediately for example the
> following directory structure:
> 
> project1
>    - src   (project1.lua)
>         - project1    (submod1.lua)
> project2
>    - src   (project2.lua)
> project3
>    - src   (project3.lua)
>  lua53  (lua.exe)
> 
> if I have ../?/src/?.lua in my package.path then all these work:
> require("project1")
> require("project2")
> require("project3")
> 
> But require("project1.submod1") does not work.

  That's an interesting solution, but how many github projects/Lua modules
will that work with?  

  -spc (I must be the odd-man out ... )