Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Knights Who Say … What?

A developer approaches a clearing in the forest. Three tall figures in horned helmets block the path.

“We are the Knights Who Say NaN! And we demand… a precondition!

The developer, who has been writing functions without contracts for years, shifts uncomfortably.

“A… precondition?”

“A precondition! One that asserts the amount is positive. And we demand it be a single expression, composed with and and or as needed. No vectors! We are very particular about our syntax.”

The developer asks “What about :pre (> amount 0)?”

“Now — we demand a postcondition!

The developer shifts nervously from foot to foot, eventually summoning enough courage to venture a muttered “So … :post (>= (get ~ :balance) 0)?”

“Now — we demand another clause! With different arities! And non-overlapping types!”

The developer, starting to get the hang of this, adds another clause. The Knights inspect it. They run the overlap checker. No conflicts are found.

“That,” says the head Knight, peering at the function through the visor of Maranget’s algorithm, “is a nice function. We will accept it.”