Re: lua_parseargs
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: lua_parseargs
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: 2001年1月24日 19:49:38 -0200 (EDT)
>> "getargs" needs access to argv, which only lua.c has.
>
>??? Surely getargs is passed argv, so it can quite happily be in a library!
>getopts works this way. Am I missing something?
As you know, a library function in Lua is a function of the form
static int f (lua_State *L) { ... }
which is then registered in Lua.
This means that you cannot send argv to f directly.
So, argv must either be available as a global variable or as an upvale,
as lua.c does for l_getargs with register_getargs. In any case, whoever
opens the library needs to give access to argv, either by copying it to
a global variable or by pushing it as an upvalue. It seems to me that
only main can do that.
--lhf