Let me simplify this a bit.
##They can exit with errors after the result is printed (or outputted in other ways)
They can exit with errors after the result is printed (or outputted in other ways)
Error messages in STDERR or those can be disabled in configurations can always be ignored. We are talking about the fatal errors which exits the program.
For function definitions, there must be a way to use the function, and retrieve the returned value (if specified in the question) without extra code to rescue from the error. However if the function does not need to return something specific, there is no reason to disallow errors in the function call as we already seemed to be allowing side effects.
For REPL it is similar. As long as the error does not stop the REPL from printing (or otherwise using) the result (if the question requires it to return something), it is fine.
If the function or REPL command printed something itself, it must really printed, not only into the internal buffer when it exited with an error.
##Then there are run-time and syntax errors.
Then there are run-time and syntax errors.
If we allow syntax errors, we'll see bash scripts exiting with )
. But that isn't too useful anyway since it cannot appear in a if
or while
group command. And it's not easy to define syntax errors in every language. I think we should just allow them.
Most source-layout questions should explicitly state that the program should exit with no errors, which usually means having the exit code 0.
Related problem: a Windows Batch file can exit the current program (using goto :eof
), or the whole cmd.exe (using exit
). Both should be fine.