lua-users home
lua-l archive

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


On Fri, Feb 3, 2017 at 1:16 AM, Scott Morgan <blumf@blueyonder.co.uk> wrote:
> On 02/03/2017 07:34 AM, Russell Haley wrote:
>> But the question was what is the argument against the approach
>> described. ‎ It always has seemed to me that Lua goes to great length
>> to search relative paths and entirely negates to look in the
>> application path for no reason whatsoever. It was one of the most
>> confusing things when I first started looking at Lua.
>
>
> Lua does use the EXE path in Windows, but under *nix systems things
> aren't so simple. There's no guarantee that the path to the executable
> exists and no clear way to determine it even if it does[0] (some hacky,
> platform dependant ways, but nothing clean).

How is that any different than the paths added via environment
variables or package paths? In fact, the majority of search parameters
will never exist (Have you seen some of the crazy search patterns
used?), but they are searched JUST IN CASE someone did something
fancy/stupid, but the path for the executing script in is not checked.


> See luaconf.h (search WIN32) and loadlib.c (search for windows.h)
>
> Personally, I go with a shell script wrapper that sets the LUA_PATH etc.
> environment vars before launching the app/Lua interpreter

Yes, there are many ways around it, but again, Lua seems to go to
great lengths to use relative paths and search hither and yander but
negates the application path arbitrarily. I say arbitrarily because
there is no good reason to NOT search it (thus far). However:

1) It makes logical sense in terms of user expectation. Running

    [user@computer~]$ lua ~/mylib/script.lua

And NOT finding all the required modules causes a dissonance that the
user must overcome. Why force this when a dead simple solution is
present?

2) It makes your code more portable. By simply checking the
application path after the current path (or potentially vis-versa)
developers can package things together and users can now run
applications from anywhere without the requirement of a script. Why
force a user to write a wrapper?

3) If the windows version of Lua does indeed search the application
path, why use two different patterns when the solution is trivial?


Cheers,

Russ