[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Acceptable indicies
- From: Robert Raschke <rtrlists@...>
- Date: Tue, 30 Aug 2011 16:39:14 +0100
On Tue, Aug 30, 2011 at 4:22 PM, oliver <firstname.lastname@example.org>
I was under the impression that the stack has a certain size (say, 20, defined when the lua lib is compiled), and that gettop just returns the index of the top-most element on that stack. So if top=10, an index is still acceptable if it refers to 11, but not if it refers to 21. Is this defined rigorously anywhere?Â
On Tue, Aug 30, 2011 at 10:58 AM, Robert Raschke <email@example.com>
Actually, on reflection that's not exactly what you're asking for. But lua_gettop (http://www.lua.org/manual/5.1/manual.html#lua_gettop) gets you the size of the stack. So these two give you what you need, or not?
On Tue, Aug 30, 2011 at 3:52 PM, Robert Raschke <firstname.lastname@example.org>
int lua_checkstack(lua_State *L, int extra);
On Tue, Aug 30, 2011 at 3:22 PM, oliver <email@example.com>
Would it be correct to say, "all functions which take a stack index
require that it is inside the available stack space",Â
or when stackspace equals X
Â ÂluaL_checkany(L,X+1) is undefined.
BTW, is there a way of knowing "available stack space"? Alternately a "bool lua_isacceptable(L, index)" would be a nice function to have.Â
I'm might be misunderstanding what you are trying to do. If you want to know if you can push more elements on to the stack then you use lua_checkstack(). If you want to know how many elements currently reside on the stack, you use lua_gettop(). I fail to see why you might want to know how many currently unused, but allocated, stack spaces lie above the current top element within it.