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

Indenting Procedure Definitions

As we hinted earlier, there's a special rule for indenting procedure definitions. You generally indent the body of a procedure a few characters (we use 3), but you don't line the body expressions up directly under the list of variable names. If you're using the Emacs editor, simply terminate each line with linefeed rather than return, and you will get a good indentation.

Don't do this:

(define (double x)
        (+ x x))

If you indent this way, a procedure definition looks like a procedure call, or a normal variable definition. To make it clearer you're defining a procedure, do this:

(define (double x)
   (+ x x))

This indentation makes it clear that the (double x) is a different kind of thing from (+ x x). The former declares how the procedure can be called, and the latter says what it will do.


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