On exceptions, errors, and contract violations

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 5 14:25:42 PDT 2014


Am Fri, 03 Oct 2014 19:46:15 +0000
schrieb "Ola Fosheim Grøstad"
<ola.fosheim.grostad+dlang at gmail.com>:

> You simply turn the "logic error" into a "cannot compute this" 
> result if that is suitable for the application. And the 
> programming language should not make this hard.

I don't get this. When we say logic error we are talking bugs
in the program. Why would anyone turn an outright bug into
"cannot compute this". When a function cannot handle division
by zero it should not be fed a zero in the first place. That's
part of input validation before getting to that point.
Or do you vote for removing these validations and wait for the
divide by zero to happen inside the callee in order to catch
it in the caller and say in hindsight: "It seems like in one
way or another this input was not computable"?

-- 
Marco



More information about the Digitalmars-d mailing list