lua-users home
lua-l archive

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


On Sun, Jun 22, 2003 at 06:09:03PM +0300, Asko Kauppi wrote:
> If dofile arguments (passing arg[1] etc. as for functions) is ever 
> going to be included in Lua, it might be a good idea to have 
> arg.filename (or arg[0]?) for the full pathname?

Lua indeed should do so and I was surpised that it doesn't set fill arg
with the parameters. What I do now is create a new environment for loaded
files (luaL_loadfile), set CURRENT_FILE in this environment to the file 
name and put a wrapper around the function that sets arg in the environment
with the parameters this function receives. I also use 'include' exported 
by my C code instead of dofile or require. It's an ugly kludge, but does 
the job.

One problem with the current file path stuff is that it is OS-specific.
(Although I am only aware of only one current OS that uses a non-standard,
i.e. non-POSIX, directory separator, I'm sure there are more.)

-- 
Tuomo