[dmd-internals] Throwing Errors

Walter Bright walter at digitalmars.com
Thu Mar 15 14:22:49 PDT 2012



On 3/15/2012 9:29 AM, Sean Kelly wrote:
> On Mar 14, 2012, at 4:42 PM, Walter Bright<walter at digitalmars.com>  wrote:
>
>>
>> On 3/12/2012 7:07 PM, Sean Kelly wrote:
>>> On Mar 12, 2012, at 5:35 PM, Walter Bright<walter at digitalmars.com>   wrote:
>>>
>>>> On 3/12/2012 2:39 PM, Sean Kelly wrote:
>>>>> On Mar 12, 2012, at 2:30 PM, Walter Bright wrote:
>>>>>> On 3/12/2012 12:34 PM, Sean Kelly wrote:
>>>>>>> I'm on the fence about whether attempting cleanup when an Error is thrown is desired behavior.  If there is no cleanup, why allow Errors to be caught at all?  We may as well simply call abort() at the point they're thrown.
>>>>>>>
>>>>>> So that an informative message can be printed, the backup engaged, attempt to shut down gracefully, log the failure details to a file, etc.
>>>>> … none of which may work if scope(exit) calls weren't run when the stack was unwound, since acquired mutexes would still be locked, etc.  I'd feel a lot less safe with having effectively done a longjmp across code that normally assumes finalization than with whatever the cause of the assertion did in the first place.
>>>>>
>>>> It's understood it may not work.
>>> So what's the reason to not call finalizers?
>>>
>> The program is corrupted at that point. The less code one attempts to run, the better.
> Is the program really corrupted though?

You cannot know that.

I really think that going down the path of thinking one can recover from 
programming bugs is the route to disaster. It goes against everything I know 
about how to make safe, reliable systems.



More information about the dmd-internals mailing list