3.3 Literals: quote and #%datum (original) (raw)

3.3 Literals: quote and #%datum🔗

Many forms are implicitly quoted (via #%datum) as literals. SeeExpansion Steps for more information.

+Quoting: quote and ’ in The Racket Guide introduces quote.

Produces a constant value corresponding to datum (i.e., the representation of the program fragment) without its lexical information, source location, etc. Quoted pairs, vectors, and boxes are immutable.

Examples:

> (quote x)
'x
> (quote (+ 1 2))
'(+ 1 2)
> (+ 1 2)
3

Expands to (quote datum), as long asdatum is not a keyword. If datum is a keyword, a syntax error is reported.

See also Expansion Steps for information on how the expander introduces #%datum identifiers.

Examples:

> (#%datum . 10)
10
> (#%datum . x)
'x
> (#%datum . #:x)
eval:6:0: #%datum: keyword misused as an expression
at: #:x