naming conventions

Some symbol naming conventions, distilled from CLHS, the Lisp FAQ, and comp.lang.lisp.

Widely used "need-to-know" conventions:

foo-bar"-" is used as a word delimiter
*foo*(global) special variable
foo*slightly different variant of the foo operator
&foolambda list keyword. These symbols will be in the lambda-list-keywords list.
nfoo(possibly) destructive (non-consing) function
fooppredicate (also foo-p); see notes below for when to hyphenate
foofplace changing (like in SETF, INCF, ...) (also foo-f)
+foo+constant, or single CLOS instance
%foolow-level, fast, dangerous function, or Lisp system specific implementation of foo
make-foocreate a foo and return it
define-foo(globally) define a new foo (also short version: "deffoo")
with-foocreate a dynamic context with a foo
do-fooiterate through a foo
foo-casefoo-specific case expression
foo-bartype-slot, converting FOO to BAR
foo-to-barconverting FOO to BAR

Often seen, but not-quite-so-common conventions:

bar-ofslot bar of an object
foo/bartype/operation, foo with bar, bar version of foo
foo.bartype.slot or, in some implementations conventional hierarchical package (e.g. ACL and CMUCL)
?foovariable in embedded language
<foo<variable in embedded language

Occasionally seen:

<foo>class
%foo%local special variable
.foo.internal special variable
.foo.private macro symbol
/foo/global lexical variable
$foofunction visible from Macsyma
foo&foo, operating on fixnums
foo$foo, operating on floats

Conventions in Scheme:

foo!destructive function
foo?predicate
$fooconstant
call-with-fooInvoke a thunk in some dynamic context
foo->barCoerce object of type foo to object of type bar

This is standard syntax, not convention:

:barkeyword
foo:barexternal symbol bar in package foo
foo::barinternal symbol bar in package foo (don't try this at home, kids!)
#:baruninterned symbol (does not belong to any package)

These will annoy people:

CamelCaseIdentifiersUse identifiers-like-this
identifiers_with_underscoresare harder to type
hungarian-identifiers-pcsnsi
abbrv-idntfrsUse Emacs to expand them.
Unless there is a good reason to use them (for instance, you need to interface to a third-party package that uses them), they should be avoided.

Some additional style notes:


This page is linked from: Getting Started  

CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively