Variable *read-suppress*

Value Type:

a generalized boolean.

Initial Value:

false.

Description:

22.1.2 25This variable is intended primarily to support the operation of the read-time conditional notations #+ and #-. It is important for the reader macros which implement these notations to be able to skip over the printed representation of an expression despite the possibility that the syntax of the skipped expression may not be entirely valid for the current implementation, since #+ and #- exist in order to allow the same program to be shared among several Lisp implementations (including dialects other than Common Lisp) despite small incompatibilities of syntax.

22.1.2 24 22.1.2 26If it is false, the Lisp reader operates normally.

Otherwise, many of the normal operations of the \term{Lisp reader} are suppressed; specifically: 22.1.2 27 \beginlist \itemitem{Extended tokens} An extended token is discarded and treated as if it were \nil; that is, reading an extended token when \varref{*read-suppress*} is \term{true} returns \nil. 22.1.2 28 \itemitem{\f{\#}} Any standard \f{\#} \term{dispatching macro character} notation that requires, permits, or disallows an infix numerical argument, such as \f{\#\i{n}R}, does not enforce any constraint on the presence, absence, or value of such an argument. 22.1.2 29 \itemitem{\tt \#\\} The \f{\#\\} notation parses as \nil. It does not signal an error even if an unknown character name is seen. 22.1.2 30 \itemitem{\tt \#B, \#O, \#X, \#R} Each of the \f{\#B}, \f{\#O}, \f{\#X}, and \f{\#R} notations scans over a following token and produces the value \nil. None of these notations signals an error even if the token does not have the syntax of a rational number. 22.1.2 31 \itemitem{\f{\#*}} \issue{SHARP-STAR-DELIMITER:NORMAL-DELIMITER} The \f{\#*} notation scans a (possibly null) token until a normal delimiter appears and produces the value \nil. It does not signal an error even if the token contains characters other of the characters \f{0} and \f{1}, or is of the wrong length. \endissue{SHARP-STAR-DELIMITER:NORMAL-DELIMITER} 22.1.2 32 \issue{SHARP-COMMA-CONFUSION:REMOVE} \itemitem{\tt \#.} The \f{\#.} notation reads the following \term{object} in suppressed mode but does not evaluate it. The \term{object} is discarded and \nil\ is produced. \endissue{SHARP-COMMA-CONFUSION:REMOVE} 22.1.2 33 \itemitem{\tt \#A, \#C, \#S, \#:} Each of the \f{\#A}, \f{\#C}, \f{\#S}, and \f{\#:} notations reads the following \term{object} in suppressed mode but does not interpret it in any way; it need not even be a \term{list} in the case of \f{\#C} or \f{\#S}, or a \term{symbol} in the case of \f{\#:}. The \term{object} is discarded and \nil\ is produced.

If the value of *read-suppress* is true, read, read-preserving-whitespace, read-delimited-list, and read-from-string all return a primary value of nil when they complete successfully; however, they continue to parse the representation of an object in the normal way, in order to skip over the object, and continue to indicate end of file in the normal way. Except as noted below, any standardized reader macro2 that is defined to read2 a following object or token will do so, but not signal an error if the object read is not of an appropriate type or syntax. The standard syntax and its associated reader macros will not construct any new objects (e.g., when reading the representation of a symbol, no symbol will be constructed or interned).

22.1.2 27

No matter what the value of *read-suppress*, parentheses still continue to delimit and construct lists; the #( notation continues to delimit vectors; and comments, strings, and the single-quote and backquote notations continue to be interpreted properly. Such situations as '), #<, (#), and #⟨Space⟩ continue to signal errors.

Examples:

\code (let ((*read-suppress* t)) (dotimes (i 4) (format t "~&input here> ") (format t "~&parsed as: ~S~%" (read)))) \OUT input here> 101 \OUT parsed as: NIL \OUT input here> (#\\a :test) \OUT parsed as: (NIL NIL) \OUT input here> '("xyz" #(a b c)) \OUT parsed as: (QUOTE ("xyz" #(NIL NIL NIL))) \OUT input here> (list 1 2 '3) \OUT parsed as: (NIL NIL NIL (QUOTE NIL)) \EV NIL \endcode

 (let ((*read-suppress* t))
   (mapcar #'read-from-string
           '("#(foo bar baz)" "#P(:type :lisp)" "#c1.2"
             "#.(PRINT 'FOO)" "#3AHELLO" "#S(INTEGER)"
             "#*ABC" "#\GARBAGE" "#RALPHA" "#3R444")))
→ (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)

Affected By:

None.

See Also:

read, Chapter 2 (Syntax)

Notes:

Programmers and implementations that define additional macro characters are strongly encouraged to make them respect *read-suppress* just as standardized macro characters do. That is, when the value of *read-suppress* is true, they should ignore type errors when reading a following object and the functions that implement dispatching macro characters should tolerate nil as their infix parameter value even if a numeric value would ordinarily be required.