Our xx
command is technically correct, but it clearly
has a few holes in it. Not only are we able to input any string, when
we do so we get a nonsensical answer.
In this chapter we’ll make our code more robust. We’ll begin by
hunting down the source of the error with the *scratch*
buffer. Once we’ve found it we’ll explore some new techniques to patch
it up: logical tests and the if
special
form. Finally, we’ll neaten up our code with the handy special form of let*
.
Our code at the end won’t do anything more than it does currently, but it will work far better and be easier on the eyes.
Learning objectives
Understand what is meant by the type of an s-expression.
Perform logical tests with booleans and the
if
special form.Use predicates to check the type of an s-expression.
Recognize and act on type errors.
Use the
let*
special form to create dependent bindings.