
The Manual says: (1)
We say that an index is valid if it lies between 1 and the stack top (that is, if 1 ? abs(index) ? top).
(2)
void lua_setfield (lua_State *L, int index, const char *k); Does the equivalent to t[k] = v, where t is the value at the given valid index index and v is the value at the top of the stack,
It follows from (1) and (2) that lua_setfield(L, LUA_REGISTRYINDEX, "some field") is incorrect, because LUA_REGISTRYINDEX is not a valid index. Is it so, or the Manual should be corrected?  Shmuel