Checkpoint: The Unbreakable Evaluator
intermediate30 min readLesson 140 of 148
Prove the discipline: an arithmetic evaluator that stays defined on every possible input.
The task
Implement eval_expr (see the challenge). Every graded case is a
boundary: saturation at INT_MAX, a number that does not fit, a malformed
grammar, NULL arguments. A "works on my machine" evaluator that computes
2147483647 + 1 in int arithmetic would be UB — and UB cannot be
trusted to fail the tests; that is precisely why the defined, saturating
implementation is the only passing one.
Passing this proves the module's thesis in one component: you can write C that processes arbitrary input with a proof-shaped guarantee — no input can push it off the defined side.
Next module: threads — making multiple things happen at once, safely.