Program logic bugs vs input/environmental errors

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 28 13:13:49 PDT 2014


On 9/28/2014 12:33 PM, Sean Kelly wrote:
>> Then use assert(). That's just what it's for.
> What if I don't want to be forced to abort the program in the event of such an
> error?

Then we are back to the discussion about can a program continue after a logic 
error is uncovered, or not.

In any program, the programmer must decide if an error is a bug or not, before 
shipping it. Trying to avoid making this decision leads to confusion and using 
the wrong techniques to deal with it.

A program bug is, by definition, unknown and unanticipated. The idea that one 
can "recover" from it is fundamentally wrong. Of course, in D one can try and 
recover from them anyway, but you're on your own trying that, just as you're on 
your own when casting integers to pointers.

On the other hand, input/environmental errors must be anticipated and can often 
be recovered from. But presenting debug traces to the users for these implies at 
the very least a sloppily engineered product, in my not so humble opinion :-)


More information about the Digitalmars-d mailing list