[GSOC] regular expressions beta is here

Dmitry Olshansky dmitry.olsh at gmail.com
Thu Aug 11 09:21:48 PDT 2011


On 11.08.2011 8:58, Don wrote:
> bearophile wrote:
>> Contracts don't replace unittests, they complement each other.
>>
>>
>>> They are nice but have little value over plain assert _unless_ we 
>>> are talking about classes and _inheritance_, which isn't the case here.
>>
>> It's easy to forget to test the output of a function, the "out" 
>> contracts help here. In structs the invariant helps you avoid 
>> forgetting to call manually a sanity test function every time you 
>> come in and out of a method.
>
> You're conflating a couple of things here. Invariants are tremendously 
> helpful for structs as well as classes.

I stand corrected about invariants, somehow I wasn't considering them a 
part of contracts.

> "out" contracts seem to be almost useless, unless you have a theorem 
> prover. The reason is, that they test nothing apart from the function 
> they are attached to, and it's much better to do that with unittesting.
> They have very little in common with 'in' contracts.
>
> I think that EVERY struct and class in Phobos should have an invariant 
> (except for something like Complex, where there are no invalid values).
> But I don't think 'out' contracts would add much value at all.


-- 
Dmitry Olshansky



More information about the Digitalmars-d mailing list