Re: LOADPATH?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: LOADPATH?
- From: Shmuel Zeigerman <shmuz@...>
- Date: 2010年11月23日 20:01:03 +0200
Luiz Henrique de Figueiredo wrote:
If I say
dofile('xxx.lua')
and xxx.lua is not in the current directory, it is an error.
Is there a way of giving Lua a path in which dofile should look
before giving up?
Try require"xxx". Then Lua will search package.path for xxx.lua.
`require' takes exactly one argument (derived from a module name) and
returns zero or one values. An arbitrary script on the other hand can
take many arguments and return many values. Thus, `require' is not a
substitution for running arbitrary scripts.
I personally am happy with a patch [1] to the Lua interpreter, that does
exactly that: search for scripts on the so-called "LUA_RPATH".
[1] http://lua-users.org/lists/lua-l/2006-01/msg00130.html
--
Shmuel