You're Doing In-Conditions Wrong

FeepingCreature feepingcreature at gmail.com
Tue Jul 14 12:11:58 UTC 2020


On Tuesday, 14 July 2020 at 12:05:23 UTC, FeepingCreature wrote:
> Something like 95% of inconditions in our codebase at least, 
> are some variant of "not null". How do you relax this 
> incondition? By not writing anything, in both proposals. You 
> certainly don't write `in (obj is null)`.
>

Addendum: Compare the type system.

If you have

```
class A
{
   void foo(A a) { }
}
class B
{
   override void foo(B b) { }
}
```

You wouldn't expect b to be typed "B or A". No, you'd expect to 
get an error. Parameter types are contravariant, not extensive; 
inconditions should follow the same logic.


More information about the Digitalmars-d mailing list