Comparing Exceptions and Errors

Adam D Ruppe destructionator at gmail.com
Sun Jun 5 11:13:48 UTC 2022


On Sunday, 5 June 2022 at 10:38:44 UTC, Ola Fosheim Grøstad wrote:
> That is a workaround that makes other languages more attractive.

It is what a lot of real world things do since it provides 
additional layers of protection while still being pretty easy to 
use.

> *Correctness **is** probabilistic.* Even in the case of 100% 
> verified code, as there is a possibility that the spec is wrong.

I'm of the opinion that the nothrow implementation right now is 
misguided. It is a relatively recent change to dmd (merged 
December 2017).

My code did and still does simply catch Error and proceed. Most 
Errors are completely harmless; RangeError, for example, is 
thrown *before* the out-of-bounds write, meaning it prevented the 
damage, not just notified you of it. It was fully recoverable in 
practice before that silly Dec '17 dmd change, and tbh still is 
after it in a lot of code.

If it was up to me, that patch would be reverted and the spec 
modified to codify the old status quo. Or perhaps redefine 
RangeError into RangeException, OutOfMemoryError as 
OutOfMemoryException, and such for the other preventative cases 
and carry on with joy, productivity, and correctness.


More information about the Digitalmars-d-learn mailing list