[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: very simple question about Lua C Function args check
- From: Francesco Abbate <francesco.bbt@...>
- Date: Sat, 27 Nov 2010 21:49:11 +0100
2010/11/27 Drake Wilson <drake@begriffli.ch>:
> I don't think I said anything about lua_gettop. I suggested that
> lua_settop was a nice way to normalize the stack height if you wanted
> to force unspecified trailing arguments to be nils regardless of what
> you pushed onto the stack later.
>
> luaL_opt* take any acceptable index, not just any valid index, so
> using those is fine too if they serve your purpose.
So, if I know that the stack was not alterated I can omit to use both
lua_settop and lua_gettop and just using lauL_optint & co like Julien
is suggesting ?
If I understood correctly, when the function is called I can assume
that all the acceptable indexes beyond the top contain either none or
nil so I can safely access them and test their values. I just need to
make sure that I didn't push any new values on the stack by myself.
Is this correct now ?
--
Francesco