Against enforce()
Kagamin
spam at here.lot
Fri Mar 18 01:14:12 PDT 2011
Walter Bright Wrote:
> 1. Asserts and contracts are for detecting program BUGS. They are not for
> validating user input, checking for disk full, file not found errors, etc.
>
> 2. Enforce is for validating user input, checking for disk full, file not found
> errors, etc. Enforce is NOT for use in contracts or checking for program bugs.
>
>
> Any use of enforce in Phobos that is checking for program bugs is itself a bug
> and should be entered into bugzilla for fixing.
So this is a bug? This is a contract, not a validation of user input.
struct Iota(N, S) if ((isIntegral!N || isPointer!N) && isIntegral!S)
{
private N current, pastLast;
private S step;
this(N current, N pastLast, S step)
{
enforce((current <= pastLast && step > 0) ||
(current >= pastLast && step < 0));
this.current = current;
this.step = step;
More information about the Digitalmars-d
mailing list