Stroustrup objects to adding Contracts to C++
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Wed Nov 11 13:46:34 UTC 2026
On 12/11/2026 2:31 AM, Paolo Invernizzi wrote:
> 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 at forum.dlang.org
>
> A lint is not enough for us, we need a compile error, and we need it to
> be transitive
So turn on warnings as error switch like dub does by default.
The exact nature of transitivity is not important atm, but it can work
like @nogc does today, minus the inference which is what can't work right.
More information about the Digitalmars-d
mailing list