Revision 1.28
Robert Brown François-René Rideau In memoriam Dan WeinrebPatterns mean "I have run out of language." — Rich Hickey
Each style point has a summary for which additional information is available by toggling the accompanying arrow button that looks this way:
. You may toggle all summaries with the big arrow button:Common Lisp is a powerful multiparadigm programming language. With great power comes great responsibility.
This guide recommends formatting and stylistic choices designed to make your code easier for other people to understand. For those internal applications and free software libraries that we develop at Google, you should keep within these guidelines when making changes. Note however that each project has its own rules and customs that complement or override these general guidelines; the speed-oriented QPX low fare search engine notably has a very different style and feel from the QRes reservation system.
If you're writing Common Lisp code outside Google, we invite you to consider these guidelines. You may find some of them useful where they don't conflict with other priorities you have. We welcome remarks and constructive feedback on how to improve our guide, and on what alternate styles work for you and why.
This guide is not a Common Lisp tutorial. For basic information about the language, please consult Practical Common Lisp. For a language reference, please consult the Common Lisp HyperSpec. For more detailed style guidance, take (with a pinch of salt) a look at Peter Norvig and Kent Pitman's style guide.
When making decisions about how to write a given piece of code, aim for the following -ilities in this priority order:
If you write a general-purpose library, or modify an existing open-source library, you are encouraged to publish the result separate from your main project and then have your project import it like any other open-source library.
You must use correct spelling in your comments, and most importantly in your identifiers.
When several correct spellings exist (including American vs English), and there isn't a consensus amongst developers as which to use, you should choose the shorter spelling.
You must use only common and domain-specific abbreviations, and must be consistent with these abbreviations. You may abbreviate lexical variables of limited scope in order to avoid overly-long symbol names.
Indent your code the way a properly configured GNU Emacs does.
Maintain a consistent indentation style throughout a project.
Indent carefully to make the code easier to understand.
You should include a description at the top of each source file.
You should include neither authorship nor copyright information in a source file.
EVAL-WHEN
, you should almost always use all of
(:compile-toplevel :load-toplevel :execute)
.
LIST
data structure.
You must follow the proper usage regarding well-known functions, macros and special forms.
&OPTIONAL
and
&KEY
arguments.
You should not use &AUX
arguments.
DYNAMIC-EXTENT
where it matters for performance,
and you can document why it is correct.
Revision 1.28
Robert Brown François-René Rideau