You're Doing In-Conditions Wrong
FeepingCreature
feepingcreature at gmail.com
Wed Jul 15 04:17:05 UTC 2020
On Tuesday, 14 July 2020 at 16:09:59 UTC, Steven Schveighoffer
wrote:
> On 7/14/20 11:37 AM, FeepingCreature wrote:
>> On Tuesday, 14 July 2020 at 13:37:58 UTC, Steven Schveighoffer
>> wrote:
>>> But I somewhat disagree. Yes, you can write bad contracts,
>>> but that is not on the compiler, and can't really be checked
>>> by the compiler. The compiler enforces the rule by ignoring
>>> what the derived class does if the parent class passes. It
>>> doesn't enforce the logic of your contract fits the rule.
>>>
>>
>> It can be checked by the compiler just fine at runtime. IMO,
>> this is what unittests are for.
>
> But the derived contracts are intended to be used only if the
> base contract fails. It's not entirely inappropriate or unheard
> of to write such a contract with that in mind.
>
Right, I agree that this is what it's intended for, I just think
that's a bad intent. It's not *entirely* inappropriate or unheard
to write such a contract, but I do think it's *almost* entirely
inappropriate and unheard. Do you have any practical examples,
not contrived i==3 cases?
More information about the Digitalmars-d
mailing list