Stroustrup objects to adding Contracts to C++

Paolo Invernizzi paolo.invernizzi at gmail.com
Wed Nov 11 13:31:24 UTC 2026


On Wednesday, 11 November 2026 at 13:23:23 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> On 12/11/2026 2:09 AM, Paolo Invernizzi wrote:
>> On Wednesday, 11 November 2026 at 12:37:58 UTC, Richard 
>> (Rikki) Andrew Cattermole wrote:
>>> [...]
>> 
>> Fair enough, I was answering about the feature, not about how 
>> dmd implements it.
>
> Unfortunately when evaluating a feature, we have to consider if 
> it can work correctly.
>
>> What we rely on is the guarantee, a compile-time check that a 
>> hot path does not allocate. We live with the attribute soup 
>> for that, also because Claude takes care of that.
>> 
>> What gives us the same guarantee in an edition without @nogc?
>> 
>> /P
>
> There are two ways to solve this that I know of, and that is 
> with function local only check, @localnogc. Which isn't 
> implemented.
>
> That'll cover your accidental closure context creation and all 
> the other kinds of GC uses.
>
> Personally I'd be ok with a lint that produces a warning, 
> turned on with a core.attribute attribute, but I know others 
> may not like this design. 
> https://forum.dlang.org/thread/tcfqveygmebplsgmexgr@forum.dlang.org

A lint is not enough for us, we need a compile error, and we need 
it to be transitive

With @nogc I'm sure that the frame loop does not allocate, also 
in the functions it calls, also in the libraries. A local check 
can't tell me that.

/P


More information about the Digitalmars-d mailing list