luamanual

What do the square brackets and numbers mean in Lua's documentation?


What does the [x, y, z] section mean in the Lua docs? You see it on every C function.

For example, lua_gettop says:

int lua_gettop (lua_State *L);

[-0, +0, –]

Returns the index of the top element in the stack. Because indices start at 1, this result is equal to the number of elements in the stack; in particular, 0 means an empty stack.

What does [-0, +0, –] mean?


Solution

  • The [-0, +0, –] section tells you how that function manipulates the Lua argument stack. There's an explanation in the Functions and Types section, but their wall of text is a bit hard to parse. I'll summarize.

    Given:

    [-o, +p, x]
    

    Those elements mean: