lua-users home
lua-l archive

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

Quoth Francesco Abbate <>, on 2010-11-27 20:09:47 +0100:
> Thank you Julien, but here is one doubt I have: can I use luaL_optint
> on the stack element 2 without checking lua_gettop before ?
> What you are suggesting is the equivalent of lua_isnoneornil plus some
> checks and nice error messages but before Drake was suggesting to use
> lua_gettop instead, at the beginning of the C function.

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.

   ---> Drake Wilson