[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **RE: Lua Tables from 'C'**
**From**: Diego Fernandes Nehab <diego@...>
**Date**: Mon, 15 Oct 2001 14:22:31 -0200 (BRST)

> I don't understand. Don't values get pushen onto the bottom of the stack??
> Or are tables different? In that case wouldn't the table be at -1?? When I
> call 'C' functions from lua with numbers as parameters, I can find them on
> the bottom of the stack. This is confusing.
The stack grows up with positive numbers. New values are pushed on the
top!
If there are 3 elements in the stack, the bottom is at 1, the middle is
at 2 and the top is at 3. If you push a new elemement, it will be at 4
and the others will keep their indexes unchanged.
You can also index elements relative to the top, using negative numbers
as indexes. If there are 3 elements in the stack, the bottom is at -3,
the middle is at -2 and the top is at -1. If you push a new elemement,
it will be at -1 and the other indexes will be decreased by one, to
reflect their new distance to the top.
So, positive indexes are absolute, negative indexes are relative to the
top. The stack grows up, new elements at the top. That's about it.
[]s,
Diego.