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 Rena once stated:
> On Sep 22, 2015 11:43 AM, "Milind Gupta" <> wrote:
> >
> >
> >>
> >> >   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!
> >>
> >> >   -spc (I must be the odd-man out ... )
> >>
> >> Well, I am with you: note that a certain Lua project has a bunch of
> >> modules with names such as "luarocks.fetch", "",
> >> and so on, and there is no main module called "luarocks".
> >>
> >> -- Hisham (let's make some T-shirts "namespacing is not a crime")
> >>
> >
> >
> > I don't think namespacing is a crime :) . But even if it is a namespace I
> > would have thought that I would want to place things with 1 namespace in a
> > particular location. Currently with org.conman.syslog and say org.conman.xx
> > and with a lua path C:\a\b\c\..\?\d\?.lua It would try to find xx and
> > syslog in 2 different directories. I would think it doesn't matter if you
> > have it as a namespace or a sub module the intention was that things inside
> > a particular redirection reside location. Maybe I am missing some other
> > cases that would fail.
> >
> It sounds like what you're saying is require("syslog") should succeed
> whether you have org.conman.syslog or or even just syslog?

 What he's saying is that given the following lua path:



	require "org.conman.syslog"

would look for

	C:/a/b/c/../org/conman/syslog/d/org/conman/syslog.lua [1]

because most modules are just <name>, not <name>.<subname>.<subsubname>.

  It also appears that he has several modules, foo, bar, baz, that all have
a similar directory structure:




And so an easy eay to reference each module is to change the lua path:


instead of installing the modules into /usr/local/share/lua/5.x/ (or
whereever).  My modules, org.conman.*, and Hisham's modules, luarocks.*,
break under that scheme.  But that he (Milind) would like a searcher that
expands the paths like:


which *could* work for Hisham's modules, but definitely not for mine [2].

  -spc (and just to mess with people, I wouldn't mind seeing Luarocks adapt
	the org.luarocks namespace 8-)

[1]	Even though org.conman.syslog is a C based module, so it would have
	a .so extension.

[2]	To test my modules, I have to install them first, as the layout I
	have is:

		orgconman/lua/table.lua	-- this is org.conman.table
		orgconman/lua/cc.lua	-- this is

		orgconman/src/syslog.c	-- this is org.conman.syslog
		orgconman/src/signal.c	-- this is org.conman.signal