Stroustrup objects to adding Contracts to C++

Indraj Gandham newsgroups at indraj.net
Mon Nov 9 18:11:52 UTC 2026


> The focus on contracts is programmer-provided run-time checks. 
> Where this approach has been tried (Eiffel, C#, macro-based 
> systems, etc.), the cost of that has led to a strategy of 
> enabling contracts while testing and removing them (or at least 
> most) in production code. This is a 1980s approach that ignores 
> about 50 years of progress involving a combination of static 
> analysis and improved implementation of range checks. 
> Furthermore, some guarantees that we want, are requested by the 
> wider community, or required by regulatory bodies are not 
> suitable for individual checks. They require rules applied to a 
> whole translation unit, or even a whole program.

I can't believe the word "Ada" is not mentioned at all in this 
document.

Also, yeah, D's contracts are a disaster, not just for the 
reasons mentioned here, but partly because they are too flexible 
and people keep putting non-trivial, so-called "business logic" 
in them.


More information about the Digitalmars-d mailing list