Comparing Exceptions and Errors

Sebastiaan Koppe mail at skoppe.eu
Mon Jun 6 06:14:59 UTC 2022


On Monday, 6 June 2022 at 04:59:05 UTC, Ola Fosheim Grøstad wrote:
> For instance if a sort function fails, then you can call a 
> slower sort function.
>
> Or in terms of actors/tasks: if one actor-solver fails 
> numerically, then you can recover and use a different 
> actor-solver.

Those are not places where you would put an assert.

The only place to put an assert is when *you* know there is no 
recovery.

Like you have been arguing, there aren't many places like that.

So don't use it.

---

9 out of 10 times when I see an assert in code review I ask the 
author to reconsider. Often it only requires a little tweak.

I guess you could say I have found asserts to be misused.


More information about the Digitalmars-d-learn mailing list