lua-users home
lua-l archive

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




On 4/18/2012 10:31 PM, Rena wrote:
On Wed, Apr 18, 2012 at 10:31, Roberto Ierusalimschy
<roberto@inf.puc-rio.br>  wrote:
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.

It's also beneficial to the programmer for the same reason. Adding an
explicit 'return' makes it harder to miss the exit point when looking
over the code.

I'm afraid to say it, but I think you are assuming what a programmer might miss. There are languages where there is no explicit return, and with explicit ones. There is also Pascal where you store the return in a special variable (if memory still serves me well). It's really hard to say what would be beneficial to the programmer. If you mean the "lua" programmer then I dunno, I myself started doodling with it just year or so ago, after several years of not using it.