[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Acceptable indicies
- From: Sean Conner <sean@...>
- Date: Wed, 31 Aug 2011 11:36:42 -0400
It was thus said that the Great oliver once stated:
>
> Programmers make mistakes when using library functions/methods, utility or
> not. For optimal productivity, a library should assert its preconditions, at
> least in debug build. It is an error *not* to check. Since some of us have
> to (for variety of reasons) use pre-built release-mode Lua DLL, where
> preconditions are therefore not asserted, and given that the
> "is-acceptable-index" formula is not trivial, and that this precondition is
> so prevalent in Lua lib, there should at least be a Lua lib function that
> allows to validate stack indices.
I think you gave the solution in another email---lua_gettop()! Here:
int mylua_isacceptable(lua_State *L,int idx)
{
return abs(idx) <= lua_gettop(L);
}
-spc (Or am I missing something?)
- References:
- Re: Acceptable indicies, oliver
- Re: Acceptable indicies, Robert Raschke
- Re: Acceptable indicies, Robert Raschke
- Re: Acceptable indicies, oliver
- Re: Acceptable indicies, Robert Raschke
- Re: Acceptable indicies, oliver
- Re: Acceptable indicies, Josh Simmons
- Re: Acceptable indicies, oliver
- Re: Acceptable indicies, Josh Simmons
- Re: Acceptable indicies, oliver