[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: About the Lua paths on Windows
- From: Stefan Sandberg <keffo.sandberg@...>
- Date: Mon, 14 May 2007 22:46:29 +0200
I fail to see the ultimate goal here, I treat the "default"
package-paths as an example of how to use it, not something that
dictates how and where I put my files.
For example, I still need two diff. builds for 32 and 64bit of luasocket.
Something that does bug me is how annoying those paths are to create in
the first place, or to debug, so if anything should be changed, I would
a very simplified helper function that makes it easy to change those
paths.. (which is usually the first thing I write anyway)
There are always people popping in to #lua asking why this'n'that isn't
loaded, and how the paths work, so I think it's justified.
Actually, while we're at it, wouldn't this fit nicely in some sort of
package-loader utility function?
Each loader is preset with a path (like what's suggested here), and also
has a function to add/remove a path from itself..?
Me rambling, ignore if it's weird, I just don't like writing those paths :)
Jerome Vuarand wrote:
Andre Carregal wrote:
The current default assumes that both the Lua executables, libraries
and the C modules go to the same directory (/), while the Lua modules
go to the /lua directory.
What about changing this to a slightly different structure:
/ (lua5.1.exe, lua5.1.dll etc)
/lib (C modules such as lfs.dll)
/lua (Lua modules such as mime.lua)
If someone is already counting on the use of "/" on package.cpath,
maybe we could make 5.1.3 look for C modules in "/" and then in
"/lib"? And maybe on Lua 5.2 we could remove the "/" from the C
Actually the package.path variable also points to / in addition to /lua.
I think the same scheme should be used for cpath. There is no reason to
remove / from the cpath. It would end as :
package.path = ".\\?.lua;"
package.path = ".\\?.dll;"
BTW I recently had some problems to redefine dynamically LUA_PATH for a
lua interpreter on windows. With the default windows shell you cannot
redefine environment variables on a per-command basis (unlike unix
shells). And to avoid polluting the current shell you have to use
setlocal/endlocal in batch files, which have further drawbacks.
It would be a nice addition to add a standard command line switch to the
stock lua interperter to override LUA_PATH and LUA_CPATH. Something
lua -p 'foo\?.lua' -cp 'bar\?.dll' -lfoo -lbar test.lua
LUA_PATH='foo\?.lua' LUA_CPATH='bar\?.dll' lua -lfoo -lbar test.lua