It was thus said that the Great Maxime Henrion once stated:
> This is of course very minor but it would be nice if this function (or
> maybe another function this one calls into) could be tagged with
> __attribute__((noreturn)) or whatever macro you guys use for this if there
> is any, if possible at all.
>
> I hope you won't mind me not looking further into this or submitting a
> patch, I thought this was trivial enough that a simple e-mail would work.
Marking a function as _Noreturn [1], but there are issues. luaL_error()
(and lua_error()) both don't return, but their signatures are such that one
can do:
return luaL_error(L,"there's an error");
to signal intent in a function that this is an exit path. Section 6.7.4.9
of the C11 standard states:
The implementation should produce a diagnostic message for a
function declared with a _Noreturn function specifier that appears
to be capable of returning to its caller.
This changes the signature of both lua_error() and luaL_error(), thus
potentially breaking a lot of code. If this were to be added, quite a bit
of code would have to be rewritten. I know I would have to rewrite quite a
bit of code if this was adapted, since I use the return luaL_error() idiom.
Also, Lua is primarily written to target C89, to be maximally portable.
-spc
[1] C11 finally standardizes this, with the new keyword _Noreturn and a
header file <stdnoreturn.h>.