Maybe D was wrong on contracts

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Wed Sep 23 20:47:24 UTC 2026


On Wednesday, 23 September 2026 at 20:40:48 UTC, Alexandru 
Ermicioi wrote:
> On Wednesday, 23 September 2026 at 14:43:13 UTC, Quirin Schroll 
> wrote:
>>
>> A string can already be null. What else than “no error” would 
>> a null string signify?
>
> an error with no message.

but really, in such cases, the expression itself can be set as 
error message.

For example index out of bound contract:
```d
T get(sizet index)
in (index < size) { ... }
```

in case of failure you can get:
```
Assertion `index < size` has failed.
```

obviuosly stack trace will show which method contract was for.


More information about the Digitalmars-d mailing list