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 |
| &foo | lambda list keyword. These symbols will be in the lambda-list-keywords list. |
| nfoo | (possibly) destructive (non-consing) function |
| foop | predicate (also foo-p); see notes below for when to hyphenate |
| foof | place changing (like in SETF, INCF, ...) (also foo-f) |
| +foo+ | constant, or single CLOS instance |
| %foo | low-level, fast, dangerous function, or Lisp system specific implementation of foo |
| make-foo | create a foo and return it |
| define-foo | (globally) define a new foo (also short version: "deffoo") |
| with-foo | create a dynamic context with a foo |
| do-foo | iterate through a foo |
| foo-case | foo-specific case expression |
| foo-bar | type-slot, converting FOO to BAR |
| foo-to-bar | converting FOO to BAR |
Often seen, but not-quite-so-common conventions:
| bar-of | slot bar of an object |
| foo/bar | type/operation, foo with bar, bar version of foo |
| foo.bar | type.slot or, in some implementations conventional hierarchical package (e.g. ACL and CMUCL) |
| ?foo | variable 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 |
| $foo | function visible from Macsyma |
| foo& | foo, operating on fixnums |
| foo$ | foo, operating on floats |
Conventions in Scheme:
| foo! | destructive function |
| foo? | predicate |
| $foo | constant |
| call-with-foo | Invoke a thunk in some dynamic context |
| foo->bar | Coerce object of type foo to object of type bar |
This is standard syntax, not convention:
| :bar | keyword |
| foo:bar | external symbol bar in package foo |
| foo::bar | internal symbol bar in package foo (don't try this at home, kids!) |
| #:bar | uninterned symbol (does not belong to any package) |
These will annoy people:
| CamelCaseIdentifiers | Use identifiers-like-this |
| identifiers_with_underscores | are harder to type |
| hungarian-identifiers-pcsnsi | |
| abbrv-idntfrs | Use Emacs to expand them. |
Some additional style notes:
p or -p. CLTL2 explains the rationale for each suffix:
By convention, the names of predicates usually end in the letter p (which stands for "predicate"). Common Lisp uses a uniform convention in hyphenating names of predicates. If the name of the predicate is formed by adding a p to an existing name, such as the name of a data type, a hyphen is placed before the final p if and only if there is a hyphen in the existing name. For example, number begets numberp but standard-char begets standard-char-p. On the other hand, if the name of a predicate is formed by adding a prefixing qualifier to the front of an existing predicate name, the two names are joined with a hyphen and the presence or absence of a hyphen before the final p is not changed. For example, the predicate string-lessp has no hyphen before the p because it is the string version of lessp (a MacLisp function that has been renamed < in Common Lisp). The name string-less-p would incorrectly imply that it is a predicate that tests for a kind of object called a string-less, and the name stringlessp would connote a predicate that tests whether something has no strings (is "stringless")!
(bar-to-baz (foo-to-bar x)) or (bar->baz (foo->bar x))) compose nicer if written the other way around: (baz-from-bar (bar-from-foo x)), (baz<-bar (bar<-foo x)).
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