[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.0 Alpha and api_incr_top
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 20 Sep 2002 10:25:44 -0300
> My situation does not fit this. Instead, it works with intertwined
> data, some of which is left on the stack for extended periods of time.
> When the process is finished, the stack is, of course, clean, but it
> can require, depending on size of data, hundreds or thousands of stack
> entries (big databases).
You could use a single table to keep your data, using integer indices
(like you do with the stack), and using the functions lua_rawgeti and
lua_rawseti. If your table is an "array" (which it will be), these
functions are very very fast. (They will not do any table lookup, only
an array access.)
About the stack: in the old days, the C stack grew automatically. The
problem was, it is very common error the unbalanced use of the stack
(e.g. loops that do not clear up the stack properly). With a dinamic
stack, those errors were seldom caught; instead, they resulted in an
ever-growing stack, with program resources disappearing without apparent
cause. So, we followed the "make your program crash earlier" principle.
-- Roberto