V. How to write functions
The form of the function definition is as follows:
(DEFUN
function_name parameter_list
function_body )
where:
- function_name is an identifier,
- parameter_list is a list (possibly empty) of identifiers, and
- function_body is an S-expression.
When writing functions, clarity is important, especially with all
those parentheses to keep track of. Here are some hints that you may
find to be helpful.
- When writing a function, begin the first line (containing the name
of the function) in column 1. Start all other lines indented by about
10 spaces, so it is easy to scan down the function names.
- When writing a conditional, put the word
COND
on a
line all by itself. Put only one clause per line, starting each clause
directly under the COND
. If you nest a second
COND
inside the first, indent the nested
COND
.
- Separate the condition and the result of a clause with extra
blanks. If a clause takes more than one line, try to break between the
condition and the result.
- Group closing parentheses according to the lines on which the
opening parentheses occurred, with blanks between groups. For example,
if the first line of a function has two open parentheses which are not
closed on the same line, then the last line should have the two
matching close parentheses together, separated from any other
parentheses by blanks. If you put
COND
on a line by
itself, then its closing parenthesis should be in a group by
itself.
Copyright © 1995 by David Matuszek
All rights reserved.
Last updated July 15, 1995