Stroustrup objects to adding Contracts to C++

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Wed Nov 11 23:59:19 UTC 2026


On 12/11/2026 11:49 AM, Walter Bright wrote:
> On 11/11/2026 4:37 AM, Richard (Rikki) Andrew Cattermole wrote:
>> Effects analysis in dmd is DOA in the type system.
>>
>> It cannot do it correctly.
> 
> It cannot do it for cyclical flow graphs, and for modules where the 
> source code is not available to the compiler.
> 
> Otherwise, it does it correctly.

I consider cyclical part of correctness.

Otherwise you end up in the situation that we've had with attribute soup 
complaints (that have valid observations!).

A solution people do not want to use (which I have used plenty! And 
defended!), is far worse than a solution people will use willingly.

>> Walter screwed up designing the architecture for dmd's semantic 
>> analysis when he designed it to be fast and not for analysis 
>> capabilities.
> 
> You keep overlooking the fact that dmd's optimizer does full DFA 
> analysis. It is restricted to intra-procedural, because inter-procedural 
> results in an exponential increase in compile times, with little 
> corresponding benefit.

Which is part of the backend, not the frontend.

It shows that you understood enough of the theory to have done it, that 
has always been known.

As for performance, this is only true for the worklist algorithm.

Its possible to not make it slow, today. But I don't think it would have 
been archivable 25 years ago. I know, because my compiler does it.

I am not overlooking anything. You picked a different tradeoff 27 years 
ago. So instead of trying of fighting it, I want us to embrace it and 
find different solutions to problems that work with it, not against it.



More information about the Digitalmars-d mailing list