Go to the first, previous, next, last section, table of contents.

Indenting let Expressions

In general, we indent let expressions in a way that shows the block structure of the program. The binding forms (variable names and initial values) are lined up vertically after the keyword let, and the body expressions are indented a few characters and lined up vertically, like so:

(let ((x 10)    ; bindings of x
      (y 20))   ; and y
   (foo x)
   (let ((a (bar))   ; bindings of a
         (b (baz)))  ; and b
      (quux x a)
      (quux y b))
   (baz))

Notice that the binding forms of each let are lined up vertically, and the body expressions are not indented as far. This is important for making it obvious where the binding forms stop and the body expressions start. (In this example, the body of the outer let consists of a call to foo, another let, and a call to baz. The body of the inner let consists of two calls to quux.)


Go to the first, previous, next, last section, table of contents.