lua-users home
lua-l archive

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

On 30 August 2011 16:22, oliver <> wrote:
> I was under the impression that the stack has a certain size (say, 20,
> defined when the lua lib is compiled),

The stack has a default size which if unchanged is 20,

> and that gettop just returns the
> index of the top-most element on that stack.


> So if top=10, an index is still
> acceptable if it refers to 11, but not if it refers to 21.

It depends on if you have requested the stack to grow and if you have
changed the default, with the default 11 would be an acceptable yet
invalid index.

> Is this defined
> rigorously anywhere?
> Oliver

Acceptable index [1]
(index < 0 && abs(index) <= top) ||
     (index > 0 && index <= stackspace)

Valid index [2]
We say that an index is valid if it lies between 1 and the stack top
(that is, if 1 ≤ abs(index) ≤ top).