Improve "Improve Contract Syntax" DIP 1009

Timon Gehr timon.gehr at gmx.ch
Mon Nov 6 15:15:45 UTC 2017


On 06.11.2017 03:32, Jonathan M Davis wrote:
> 
> I'm sure that there are various things that could be done to improve
> contracts (and DIP 1009 is one such attempt), but I've mostly given up on
> it. I don't think that they provide enough value in the first place. Aside
> from issues involving contracts and inheritance, in contracts can just be
> put in the function body,

The point of the in contract is to establish that it is the caller, and 
not the library author, who is responsible for ensuring it is satisfied.
It is slightly more obvious why this is crucial if your language has 
tooling for verifying assertions.

> making them kind of pointless, and for the most
> part, unit tests test anything that I would consider testing in an out
> contract

Then you are doing it wrong.

> - and generally do it better.

Unit tests alone do not test your code better than both unit tests and 
contracts.


More information about the Digitalmars-d mailing list