Reconsidering a Scheme formatting convention

NOTE HXA7241 2011-08-14T09:44Z

A hugely important matter of getting source-code just right.

Rule

Format (if ...) branch-clauses with an indent (normally two spaces):

(if (predicate ...)
  (true branch ...)
  (false branch ...))

Rationale

It seems common to format (if ...) branch-clauses with alignment – they vertically align with the predicate clause. But this is actually inconsistent.

Consider the often used forms: (define ...) (do ...) (lambda ...) (case ...) (let ...) are indented, but (begin ...) (cond ...) (and ...) (or ...) are aligned. The implicit rule seems to be this: indented forms have a special first element – e.g. the ‘name’ in (define ...), aligned forms do not – all elements are basically equivalent.

(if ...) does have a special first element, so it ought to go in the indenting group.