On Thursday, 5 February 2015 at 06:41:59 UTC, Daniel Murphy wrote:
"Meta" wrote in message news:[email protected]...

I don't know about others (besides Beatophile, who religiously adheres to writing contacts), but putting contracts on functions is a hassle. I never do it unless I'm feeling particularly full of divine fervor. It's a lot like making all variables that don't need to be changed immutable (another thing which only Bearophile seems to do) or properly documenting code. Strong optimization guarantees from contracts would go a long way in convincing people to actually write them (although I guess that's not what you want; Perhaps you changed your mind). It's a chicken and egg problem.

Would you be more likely to write contracts if something like this was implemented?
https://github.com/D-Programming-Language/dmd/pull/3799

I want to check contracts at compile time, when possible. For me this would make contracts 1000x more useful.

I have seen that PR previously, and I do hope it gets merged. It is a step in the right direction; contracts may turn out to be a veritable goldmine of opportunities from optimization, such as Walter's desire to have assert() also mean assume(). Using contracts for optimization purposes is really a win-win, as it would make contract-based code both more correct AND faster. I think the best way to evangelize DbC is not that it's the correct thing to do, but because it makes code faster. That's obviously not the case with D yet, but I hope we get there someday.

Reply via email to