DIP33: A standard exception hierarchy

John Colvin john.loughran.colvin at gmail.com
Fri Apr 5 12:39:13 PDT 2013


On Friday, 5 April 2013 at 13:42:02 UTC, deadalnix wrote:

> Right now, it isn't even possible to try a graceful shutdown 
> when really, the program is unlikely to be in a completely 
> unpredictable state, especially in @safe code.

It is possible. Catch the error.

However, having the language pretend that it can make any logical 
guarantees to you like it does with exceptions (i.e. finally 
blocks, chaining etc.) only encourages people not to take Errors 
as seriously as one should.
Soon people are throwing errors where they should be exceptions 
and vice versa. Even worse: people will be catching errors 
everywhere and their code could be happily running for days 
performing undefined behaviour.

This is a similar situation to shared (although with some 
important differences). Making it easier to use would be like 
putting a seatbelt on a motorbike. Sure, it might be safer some 
of the time. It'll definitely require less care to use. But when 
the bike slips sideways underneath you going round a bend at 
80mph, you need to kick it away as fast as possible.
It'll save you all the times it *doesn't* matter, but it'll kill 
you that one time when it *does*.


More information about the Digitalmars-d mailing list