Doc Comments /
DBC
Difference (last change) (no other diffs, normal page display)
Changed: 5,6c5,12
== Messages = Put your comments about the official/non-official page here. |
== Comments == Put your comments here. === Unimplemented Feature === Inheritance of in/out contracts in an unimplemented feature ( ![]() |
Changed: 50c56
== No support for "old" in postconditions = |
=== No support for "old" in postconditions === |
Changed: 66c72
== Broken link = |
=== Broken link === |
Deleted: 70,71d75
== Amendments = You may add a link to this page on the DocumentationAmendments page to draw extra attention to your suggestion. |
Changed: 73,74c77,81
== Links = See the corresponding page in the D Specification: ![]() |
== Links == * Corresponding page in the D Specification ** ![]() ** ![]() |
Contract Programming
![]() |
|
Comments
Put your comments here.
Unimplemented Feature
Inheritance of in/out contracts in an unimplemented feature ( Issue:302).
Errors/Exceptions
Currently there are no InException, OutException or InvariantException in Phobos. Just AssertError...
square_root example
In the square_root example for DBC, what is funny is that the out clause will assert quite a lot: the x and result are of type long, so it means each time the parameter x is not a 'perfect square', assert((result * result) == x) will fail. A very good example!
The sample code is obsolete and won't compile with ver 0.102. Casts are needed, and math.sqrt is now std.math.sqrt
![]() |
|
Suggested Example
Suggestion for another example for a one-based lookup table. Zero is not a valid index to lookup table, and return value must be in certain range.
![]() |
|
No support for "old" in postconditions
Unfortunately D lacks Eiffel's "old" or any equivalent mechanism for the postcondition ("out") statements to refer to the original value which "this" had at the start of the function call.
Full Design By Contract includes a way to compare the object's values at the start and end of the function invocation, which is often necessary in order to define what the function does to the object.
( http://archive.eiffel.com/doc/manuals/technology/contract/ gives further discussion of this element of DBC.)
Thus something like
![]() |
|
Broken link
The link to Adding Contracts to Java should be http://jan.netcomp.monash.edu.au/java/contracts/paper-long.html.
Links