Exception/Error division in D

deadalnix deadalnix at gmail.com
Fri Jun 1 11:14:45 PDT 2012


Le 01/06/2012 02:57, Walter Bright a écrit :
> On 5/31/2012 2:23 AM, Lars T. Kyllingstad wrote:
>> On Thursday, 31 May 2012 at 02:18:22 UTC, Walter Bright wrote:
>>> A recoverable exception is NOT a logic bug in your program, which is
>>> why it is
>>> recoverable.
>>>
>>> If there is recovery possible from a particular assert error, then
>>> you are
>>> using asserts incorrectly.
>>
>> I think this is a key point. Asserts are there to verify and debug
>> program
>> logic, they are not part of the logic itself. They are a useful tool
>> for the
>> programmer, nothing more. Specifically, asserts are NOT an error handling
>> mechanism!
>
> Right. And I'd like to amplify that the asserts are also there to detect
> program faults hopefully before damage is done.
>
> If a program must continue even after it has failed, then you have a
> WRONGLY designed system.
>
> It is extremely important to understand this point if you are
> implementing any sort of critical software.

We are talking about runing scope statement and finally when unwiding 
the stack, not trying to continue the execution of the program.

This is, most of the time, the point of error/exceptions. You rarely 
recover from them in real life.


More information about the Digitalmars-d mailing list