lua-users home
lua-l archive

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

2010/3/3 Ignacio Burgueño <>:
> { 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