lua-users home
lua-l archive

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


> My first question is: why don't public API functions also use that attribute ?
> Those external functions could be declared as 'noreturn':
> 
> LUA_API int   (lua_error) (lua_State *L);
> LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
> LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
> 
> I may have an answer: maybe it is because they return a dummy 'int' value.

Right. A second problem is related to 'noreturn' not being standard; we
actually would have an API that changes with the compiler.


> A second question arises: is there any benefit to write 'return
> lua_error(L)' instead of just 'lua_error(L)' ?

We hope there is. It gives the compiler the same kind of information
that 'noreturn' gives, namely that the function will not continue
executing after 'lua_error' was called.


> Is this the reason why lua_error returns an 'int' instead of 'void' ?

Yes.

-- Roberto