D contract programming lacks the 'old', but there is another different problem.

Allowing only asserts (and calls to only pure/readonly functions) in 
precoditions, postconditions and invariants opens the door for future software 
that perform automatic compile-time verification of contracts.

Putting all kind of D code inside contracts will make them very hard to 
statically verify.

But simple asserts sometimes are not enough to test more complex things. So 
other more serious contract systems allow for asserts that contain forall, max, 
min, sets, and few more simple things, this is an example from a system for 
Java:

/*@ assert (\forall int i; 0 <= i && i < n; a[i] != null);

Beside keeping the door open to future automatic verification, that short style 
for conditions helps keep them shorter and less buggy (also because it helps 
psychological 'chunking'). If code inside contracts is long and complex then it 
too can contain bugs.

Bye,
bearophile

Reply via email to