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
modules path.
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;"
.."!\\lua\\?.lua;"
.."!\\lua\\?\\init.lua;"
.."!\\?.lua;"
.."!\\?\\init.lua"
package.path = ".\\?.dll;"
.."!\\lib\\?.dll;"
.."!\\lib\\loadall.dll;"
.."!\\?.dll;"
.."!\\loadall.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
like:
lua -p 'foo\?.lua' -cp 'bar\?.dll' -lfoo -lbar test.lua
instead of:
LUA_PATH='foo\?.lua' LUA_CPATH='bar\?.dll' lua -lfoo -lbar test.lua