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 Russell Haley once stated:
> On Fri, Feb 3, 2017 at 4:28 PM, Sean Conner <sean@conman.org> wrote:
> >   So add it to your Lua application.  That way, you don't have to wait for
> > the Lua team to add it.
>
> I have counter arguments but that's not the point. The only reason I
> spoke up is because I ran into this myself when I was starting with
> Lua. The way it searches the current path and chooses the defaults to
> search is opaque to casual users. The simple fact is Lua searches a
> number of places for a variety of things to help the user out but
> negates this simple yet effective addition that won't break any other
> operating environment because you won't be using path separators if
> there is no filesystem. It provides huge functionality, doesn't break
> anything, provides continuity between that "other small operating
> system" that Lua supports, is 100% backwards compatible (because
> nobody could do it before) and is as simple as saving the results of a
> one time tokenization (is that the right word?). The best answer to
> "why not?"  is "because that's not the way we did it before". Fair
> enough, but I agree with the OP that it's a puzzling omission. And
> this is coming from a guy who likes to start counting from 1.

  Again, add it to your Lua application if it's so important to you.  

  But okay, let's add the feature.

  Where do you add the "application path"?  Do you prepend it to
package.path?  Or append it to package.path?  And if you don't think it
makes a difference, it does:

	GenericUnixPrompt> luawhich org.conman.parsers.email
	/home/spc/.luarocks/share/lua/5.1/org/conman/parsers/email.lua
	/usr/local/share/lua/5.1/org/conman/parsers/email.lua
  
  See, I need to test my modules via LuaRocks, which is why I have this one
installed twice (once by me doing development, and once by LuaRocks to test
that method of installation---which reminds me, I probably need to remove
the LuaRocks version).  By default, Lua will install the first one it finds
with the given name.  You can get different results depending if a directory
is prepended or appended.

  Will this problem come up often enough in practice?  I don't know, but
having Lua do it automatically is *NOT* 100% safe (especially given the
number of modules having the same name, like "zlib" [1] or "syslog" [2]),
and even those wanting the feature will probably argue about where to add
the paths.

  Then there's the issue of where in Lua itself.  Do you add it to liblua.a
(or lua.dll for those on Windows)?  Or to the standalone Lua interpreter?

  -spc (Not so simple now ... )

[1]	A simple Google search for "lua zlib" revealed at least three Lua
	modules called "zlib" with differing APIs.

[2]	I know of at least four different Lua modules to syslog, three of
	which have the same name.