Le 01/06/2012 22:35, Walter Bright a écrit :
On 6/1/2012 11:14 AM, deadalnix wrote:
We are talking about runing scope statement and finally when unwiding
the stack,
not trying to continue the execution of the program.
Which will be running arbitrary code not anticipated by the assert
failure, and code that is highly unlikely to be desirable for shutdown.
This is, most of the time, the point of error/exceptions. You rarely
recover
from them in real life.
I believe this is a misunderstanding of what exceptions are for. "File
not found" exceptions, and other errors detected in inputs, are routine
and routinely recoverable.
This discussion has come up repeatedly in the last 30 years. It's root
is always the same - conflating handling of input errors, and handling
of bugs in the logic of the program.
The two are COMPLETELY different and dealing with them follow completely
different philosophies, goals, and strategies.
Input errors are not bugs, and vice versa. There is no overlap.
I'm pretty sure I understand what you are saying here. We have in fact 3
cases :
1/ A problem during the execution of an operation (Exceptions).
2/ A logical invalid state in the program (Errors).
3/ The program environment is broken (Error too ATM).
Case 1/ is out of the current discussion scope. In case 3/, it doesn't
even make sense to throw an Error as we do know, because it isn't even
sure that this is possible (stack corrupted), or that the information
provided are correct.
This leave the case 2/ on the table.
Programs are usually an aggregate of several smaller component that
interacts with each others. Let say, as this is a very common case, I
have a program that have a network component and another that perform
some calculations.
If an assert fails in the component that does calculations, it indicate
a malfunction here. Whatever I do in that module, it is likely that it
will make no sense. However, unless I consider I may be in case 3/ (but
then, it isn't even a good response to throw an Error, so we consider we
aren't) I'm sure that the network module is still in good shape and can
close the connection.