Norbert Nemec wrote:
I agree that contracts offer too much liberty. However, I would actually
go one step further than bearophile:
I find the need for "assert" statements not only superfluous but
actually misleading. A contract violation is something conceptionally
different from a broken assertion. Assertions and contracts have
different purposes.
In what way are their purposes different?
In my opinion, contracts should not be lists of statements but simply
boolean expressions that have to evaluate to true. Contract checks would
then become decoupled from assertion checks. Both could be switched
independently at compile time.
For any case where the contract is more complex than what can be handled
by an expression, one should simply define a pure function, which would
even help to unclutter the code and keep contract short and concise to
read.
I think that's a stylistic issue, not a language one.