GotW #98: Assertion levels (Difficulty: 5/10)
This special Guru of the Week series focuses on contracts. We covered basic assertions in GotW #97… but not all asserted conditions are created equal. JG Questions Given some assertion syntax: 1. Give one example each of an asserted condition whose run-time evaluation is: a) super cheap b) arbitrarily expensive Guru Questions 2. What does … Continue reading GotW #98: Assertion levels (Difficulty: 5/10) →
This special Guru of the Week series focuses on contracts. We covered basic assertions in GotW #97… but not all asserted conditions are created equal.
JG Questions
Given some assertion syntax:
SomeAssert( condition ); // expresses that ‘condition’ must be true
1. Give one example each of an asserted condition whose run-time evaluation is:
a) super cheap
b) arbitrarily expensive
Guru Questions
2. What does the answer to Question 1 imply for assertion checking? Explain.
3. Give an example of an asserted condition that is in general impossible to evaluate, and so cannot be checked. Can these kinds of conditions still be useful?
4. How do these questions help answer:
a) what “levels” of asserted conditions we should be able to express?
b) why the assertions we can “practically” write are a subset of all the ones we might “ideally” like to write?