Maybe D was wrong on contracts
Quirin Schroll
qs.il.paperinik at gmail.com
Tue Sep 8 20:02:15 UTC 2026
On Monday, 17 August 2026 at 19:23:31 UTC, H. S. Teoh wrote:
> On Mon, Aug 17, 2026 at 06:57:04PM +0000, Quirin Schroll via
> Digitalmars-d wrote:
>> TL;DR: D’s contracts are theoretically unsound, but there’s an
>> easy fix.
> [...]
>> Maybe C++ got something right, or rather, D got something
>> wrong that C++ got right-er:
>>
>> *A virtual function’s postconditions don’t get limit what
>> overriders do when invoked with arguments that don’t satisfy
>> its preconditions.*
>>
>> The violation of this principle might be the reason why D’s
>> contracts never took off.
> [...]
>
> IMO, the reason D's contracts never took off is because they
> are too complex to reason about when mixed with inheritance /
> polymorphism.
They might be hard to reason about because the way they work is
unreasonable. (Sounds like a pun, but I mean it literally.)
More information about the Digitalmars-d
mailing list