Why can the parameter `n` of function l`ua_upvalueindex` be 256?

90 views Asked by At

Hi~ I need some helps as i couldn't understand c closures in lua reference manual. As follows:

2)

void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
...
The maximum value for n is 255.
...

1)

Any access to lua_upvalueindex(n), where n is greater than the number of upvalues of the current function (but not greater than 256, which is one plus the maximum number of upvalues in a closure), produces an acceptable but invalid index.

Both 1) and 2) are descriptions in Lua reference manual. And I am puzzled:

Why can the argument n of lua_upvalueindex be 256 when the maximum number of upvalues is 255?

Could anybody help me?

0

There are 0 answers