Program logic bugs vs input/environmental errors

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sat Oct 18 10:40:37 PDT 2014


On 10/18/2014 8:21 AM, Jacob Carlborg wrote:
> On 2014-10-18 07:09, Walter Bright wrote:
>
>> Which means they'll be program bugs, not environmental errors.
>
> Yes, but just because I made a mistake in using a function (hitting an assert)
> doesn't mean I want to have undefined behavior.


As I've said before, tripping an assert by definition means the program has 
entered an unknown state. I don't believe it is possible for any language to 
make guarantees beyond that point.

Now, if it is a "known" unknown state, and you want to recover, the solution is 
straightforward - use enforce(). enforce() offers the guarantees you're asking for.

Using assert() when you mean enforce() is like pulling the fire alarm but not 
wanting the fire dept. to show up.


More information about the Digitalmars-d mailing list