lua-users home
lua-l archive

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

Apologies for another silly little question.

In C code, for 5.1, if I call luaL_checkudata but the index doesn't exist (say I was expecting an arg but none was provided), is that OK (and I get expected failure) or is that somehow bad or undefined?

The docs just say:

luaL_checkudata: Checks whether the function argument narg is a userdata of the type tname (see luaL_newmetatable).

In the implementation, I can see it calls:

lua_touserdata: If the value at the given acceptable index is a full userdata, returns its block address. If the value is a light userdata, returns its pointer. Otherwise, returns NULL.

So I guess my question is whether, if I was expecting an arg and it wasn't provided, is that an "acceptable index?" (Or, if it's not acceptable, that's the "otherwise" clause?)