[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Moving an element on the stack
- From: Peter Cawley <lua@...>
- Date: Wed, 3 Mar 2010 13:23:58 +0000
2010/3/3 Ignacio Burgueño <ignaciob@inconcertcc.com>:
> { aTable, aFunction, aValue1, ... aValueN }
> 2) Save the top, set it to point at the function, insert it below 'aTable'
> and restore the top.
> top = gettop(L)
> settop(L, 2)
> insert(L, 1)
> settop(L, top)
This will yield a stack containing {aFunction, aTable, nil1, ...,
nilN} as settop(2) effectively throws away everything after the first
two elements (technically, settop(2) just marks everything after 2 as
garbage-collectable, and settop(top) puts in the nils - "If the new
top is larger than the old one, then the new elements are filled with
nil").