Previous: , Up: Introduction   [Contents][Index]

15.1.7 Overview of Syntax

Certain characters are used in special ways in the syntax of Common Lisp. The complete syntax is explained in detail in chapter 22, but a quick summary here may be useful:

left parenthesis ‘(

begins a list of items. The list may contain any number of items, including zero. Lists may be nested.

  • For example, (cons (car x) (cdr y)) is a list of three things, of which the last two are themselves lists.
right parenthesis ‘)

ends a list of items.

acute accent ‘'

(also called single quote or apostrophe) followed by an expression form is an abbreviation for (quote form). Thus 'foo means (quote foo) and '(cons 'a 'b) means (quote (cons (quote a) (quote b))).

semicolon ‘;

the comment character. It and all characters up to the end of the line are discarded.

double quote ‘"

surround character strings:

"This is a thirty-nine-character string."
Backslash ‘\

is an escape character. It causes the next character to be treated as a letter rather than for its usual syntactic purpose.

Vertical bars ‘|

are used in pairs to surround the name (or part of the name) of a symbol that has many special characters in it. It is roughly equivalent to putting a backslash in front of every character so surrounded.

Number sign ‘#

signals the beginning of a complicated syntactic structure. The next character designates the precise syntax to follow.

Grave accent (“backquote”) ‘`

signals that the next expression is a template that may contain commas. The backquote syntax represents a program that will construct a data structure according to the template.

Commas ‘,

are used within the backquote syntax.

Colon ‘:

is used to indicate which package a symbol belongs to. For example, network:reset denotes the symbol named reset in the package named network.

  • A leading colon ‘:’ indicates a keyword, a symbol that always evaluates to itself. The colon character is not actually part of the print name of the symbol. A symbol notated with a leading colon is in effect a constant that evaluates to itself.

Brackets, braces, question mark, and exclamation point (that is, ‘[’, ‘]’, ‘{’, ‘}’, ‘?’, and ‘!’) are not used for any purpose in standard Common Lisp syntax. These characters are explicitly reserved to the user, primarily for use as macro characters for user-defined lexical syntax extensions.



All code in this book is written using lowercase letters. Common Lisp is generally insensitive to the case in which code is written.


Internally, names of symbols are ordinarily converted to and stored in uppercase form.

Case Conversion—*print-case*

There are ways to force case conversion on output if desired; see *print-case*.

Case In This Book

In this book, wherever an interactive exchange between a user and the Lisp system is shown, the input is exhibited with lowercase letters and the output with uppercase letters.


X3J13 voted in June 1989 (READ-CASE-SENSITIVITY) to introduce readtable-case. Certain settings allow the names of symbols to be case-sensitive. The default behavior, however, is as described in the previous paragraph. In any event, only uppercase letters appear in the internal print names of symbols naming the standard Common Lisp facilities described in this book.

Previous: The Lisp Reader, Up: Introduction   [Contents][Index]