next up previous contents index
Next: Predicates and clauses Up: Layout Rules Previous: Layout Rules   Contents   Index

General guidelines

Code should be indented consistently. Tabs should be every 8 spaces. Indentation should be one tab per level of indentation, except for highly indented code which may be indented at 4 spaces per level of indentation after the first.

Each line should not extend beyond 79 characters, unless this is necessary due to the use of long string literals. If a statement or predicate call is too long, continue it on the next line indented two levels deeper. If the statement or call extends over more than two lines, then make sure the subsequent lines are indented to the same depth as the second line. For example:

Here is A_really_long_statement_that_does_not_fit +
           On_one_line + In_fact_it_doesnt_even_fit +
           On_two_lines.
Don't put more than one statement or call on a line.

Put spaces after commas in comma-separated lists. Put spaces either side of infix operators. In both cases, this makes them easier to read, particularly in expressions containing long names or names with underscores. (There are some exceptions, such as module qualification foo:bar and functor/arity pairings foo/3. But not unification X = Y or list consing [Head | Tail].)

Make judicious use of single blank lines in clause bodies to separate logical components.


next up previous contents index
Next: Predicates and clauses Up: Layout Rules Previous: Layout Rules   Contents   Index
Warwick Harvey
2004-08-07