[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: More lua stack operations support?
- From: Jean-Luc Jumpertz <jean-luc@...>
- Date: Mon, 3 Mar 2014 09:50:14 +0100
Le 1 mars 2014 à 10:25, Xavier Wang <weasley.wx@gmail.com> a écrit :
> a multi-version of lua_remove is very most important -- to implement a proper vaeriosn of lua_removevalues need careful, a loop of lua_remove will cause O(n^2) behavior :-(
>
Le 1 mars 2014 à 13:36, Roberto Ierusalimschy <roberto@inf.puc-rio.br> a écrit :
> (lua_remove and lua_insert, however, due to their non-constant cost,
> may be worth considering.)
From my experience after writing 25K lines of code using intensively the Lua C API, actually lua_remove (range) would be a valuable addition.
In effect, it corresponds to a real and rather common use case where:
- you want to push several "result" values to the stack,
- for this you need to compute a number of intermediate stuff like table references and so push these intermediate values in the stack
- you compute your "result" values that are located at the top of the stack
- you need to remove the intermediate values from the stack in order to leave it in a clean non-leaking state
IMHO no other additional stack operation is really needed.
Jean-Luc