On exceptions, errors, and contract violations

Sean Kelly via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 3 11:31:20 PDT 2014


On Friday, 3 October 2014 at 17:51:16 UTC, monarch_dodra wrote:
>
> Also, I don't think "postconditions" are meant to check 
> "callee" errors. That's what asserts do. Rather, postconditions 
> are verifications that can ony occur *after* the call. For 
> example, a function that takes an input range (no length), but 
> says "input range shall have exactly this amount of items..." 
> or "input shall be no bigger than some unknown value, which 
> will cause a result overflow".

It sounds to me like we're saying the same thing.  Postconditions
test whether the function did the right thing.  This might be
validating the result or validating some internal state.


More information about the Digitalmars-d mailing list