Version: 4.1

4.10 Quoting: quote and

Literals: quote and #%datum in Reference: PLT Scheme also documents quote.

The quote form produces a constant:

(quote datum)

The syntax of a datum is technically specified as anything that the read function parses as a single element. The value of the quote form is the same value that read would produce given datum.

To a good approximation, the resulting value is such that datum is the value’s printed representation. Thus, it can be a symbol, a boolean, a number, a (character or byte) string, a character, a keyword, an empty list, a pair (or list) containing more such values, a vector containing more such values, a hash table containing more such values, or a box containing another such value.

Examples:

  > (quote apple)

  apple

  > (quote #t)

  #t

  > (quote 42)

  42

  > (quote "hello")

  "hello"

  > (quote ())

  ()

  > (quote ((1 2 3) #("z" x) . the-end))

  ((1 2 3) #("z" x) . the-end)

  > (quote (1 2 . (3)))

  (1 2 3)

As the last example above shows, the datum does not have to be the normalized printed form of a value. A datum cannot be a printed representation that starts with #<, however, so it cannot be #<void>, #<undefined>, or a procedure.

The quote form is rarely used for a datum that is a boolean, number, or string by itself, since the printed forms of those values can already be used as constants. The quote form is more typically used for symbols and lists, which have other meanings (identifiers, function calls, etc.) when not quoted.

An expression

'datum

is a shorthand for

  (quote datum)

and this shorthand is almost always used instead of quote. The shorthand applies even within the datum, so it can produce a list containing quote.

Reading Quotes in Reference: PLT Scheme provides more on the shorthand.

Examples:

  > 'apple

  apple

  > '"hello"

  "hello"

  > '(1 2 3)

  (1 2 3)

  > (display '(you can 'me))

  (you can (quote me))