[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Moving an element on the stack
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Wed, 3 Mar 2010 09:51:49 -0300
> I have something like this in the stack (from bottom to top)
> { aTable, aFunction, aValue1, ... aValueN }
>
> What I want is to put aFunction below aTable.
If you want to exchange aTable and aFunction, there's a third way:
lua_pushvalue(L, 1);
lua_pushvalue(L, 2);
lua_replace(L, 1);
lua_replace(L, 2);
At least this avoids the data movemement implied by lua_insert.
In Lua 5.2 you'll be able to do this:
lua_pushvalue(L, 1);
lua_copy(L, 2, 1);
lua_replace(L, 2);