lua-users home
lua-l archive

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

On 22/02/2013 11:40, Roberto Ierusalimschy wrote:
>> 2. I've written a vararg function which builds up a lot of stuff on
>> top of the vararg, but the vararg itself is not returned. There
>> seems not to be a cheap API function for removing contiguous buried
>> items, you have to do it one at a time. That's O(n^2) if the number
>> 'n' of items to remove is the same the depth to which they are
>> buried. Is it in any way perilous just to leave them there?
> Not at all. It is expected. (The 'int' return in lua_Cfunction
> exists only to allow this.)
Also if you are not about to return immediately, you can use
lua_insert() to move the wanted value to the bottom of the stack,
followed by lua_pop(n) to remove the unwanted values that are now above it.

-- Finn