2
2
3
3
$(COMMUNITY D's Contract Programming vs C++'s,
4
4
5
+ $(HEADERNAV_TOC)
6
+
5
7
$(P Many people have written me saying that D's Contract Programming
6
8
does not add anything that C++ does not already support.
7
9
They go on to illustrate their point with a technique for doing Contracts in
@@ -16,7 +18,7 @@ $(COMMUNITY D's Contract Programming vs C++'s,
16
18
to support Contracts, but they are not covered here because they are not
17
19
part of standard C++ and are not supported by any other C++ compiler.)
18
20
19
- $(H2 Contract Programming in D)
21
+ $(H2 $(LNAME2 contract-programming-d, Contract Programming in D) )
20
22
21
23
This is more fully documented in the D
22
24
<a href="contracts.html">Contract Programming</a> document.
@@ -64,9 +66,9 @@ $(H2 Contract Programming in D)
64
66
65
67
)
66
68
67
- $(H2 Contract Programming in C++)
69
+ $(H2 $(LNAME2 contract-progamming-cpp, Contract Programming in C++) )
68
70
69
- $(H3 The $(D assert) Macro)
71
+ $(H3 $(LNAME2 assert-macro, The $(D assert) Macro) )
70
72
71
73
$(P C++ does have the basic $(D assert) macro, which tests its argument
72
74
and if it fails, aborts the program. $(D assert) can be turned
@@ -80,7 +82,7 @@ $(H3 The $(D assert) Macro)
80
82
$(P $(D assert) is where explicit support for Contracts in Standard C++
81
83
begins and ends.)
82
84
83
- $(H3 Class Invariants)
85
+ $(H3 $(LNAME2 class-invariant, Class Invariants) )
84
86
85
87
Consider a class invariant in D:
86
88
@@ -215,7 +217,7 @@ int A::foo()
215
217
The #if DBC is still there because some compilers may not
216
218
optimize the whole thing away if check_invariants compiles to nothing.
217
219
218
- $(H2 Preconditions and Postconditions)
220
+ $(H3 Preconditions and Postconditions)
219
221
220
222
Consider the following in D:
221
223
@@ -366,7 +368,7 @@ int foo(int a, int b)
366
368
}
367
369
)
368
370
369
- $(H2 Preconditions and Postconditions for Member Functions)
371
+ $(H3 $(LNAME2 pre-post-conditions, Preconditions and Postconditions for Member Functions) )
370
372
371
373
Consider the use of preconditions and postconditions for a
372
374
polymorphic function in D:
@@ -464,7 +466,7 @@ public:
464
466
and parameters
465
467
for $(D foo()).
466
468
467
- $(H2 Conclusion)
469
+ $(H2 $(LNAME2 conclusion, Conclusion) )
468
470
469
471
$(P These C++ techniques can work up to a point. But, aside from
470
472
$(D assert), they are not standardized and so will vary from
@@ -476,7 +478,7 @@ $(H2 Conclusion)
476
478
way to use Contracts and get it right. Being in the language standardizes
477
479
the way it will be used from project to project.)
478
480
479
- $(H2 References)
481
+ $(H2 $(LNAME2 references, References) )
480
482
481
483
$(P Chapter C.11 introduces the theory and rationale of
482
484
Contract Programming in
@@ -495,5 +497,6 @@ $(H2 References)
495
497
496
498
Macros:
497
499
TITLE=D's Contract Programming vs C++'s
500
+ SUBNAV=$(SUBNAV_ARTICLES)
498
501
499
502
0 commit comments