A macro definition from a character such as " can be copied to another character; the standard definition for " looks for another character that is the same as the character that invoked it. The definition of ( can not be meaningfully copied to {, on the other hand. The result is that lists are of the form {a b c), not {a b c}, because the definition always looks for a closing parenthesis, not a closing brace.
(set-syntax-from-char #\7 #\;) => T 123579 => 1235
The to-readtable is modified.
The existing values in the from-readtable.
@xref{set-macro-character; get-macro-character} , section make-dispatch-macro-character [Function] , section Character Syntax Types
The constituent traits of a character are "hard wired" into the parser for extended tokens. For example, if the definition of S is copied to *, then * will become a constituent that is alphabetic_2 but that cannot be used as a short float exponent marker. For further information, see section Constituent Traits.
with-standard-io-syntax {form}{*} => {result}{*}
forms---an implicit progn.
results---the values returned by the forms.
Within the dynamic extent of the body of forms, all reader/printer control variables, including any implementation-defined ones not specified by this standard, are bound to values that produce standard read/print behavior. The values for the variables specified by this standard are listed in Figure 23--1.
[Reviewer Note by Barrett: *print-pprint-dispatch* should probably be mentioned here, too.]
Variable Value *package* The CL-USER package *print-array* t *print-base* 10 *print-case* :upcase *print-circle* nil *print-escape* t *print-gensym* t *print-length* nil *print-level* nil *print-lines* nil *print-miser-width* nil *print-pprint-dispatch* The standard pprint dispatch table *print-pretty* nil *print-radix* nil *print-readably* t *print-right-margin* nil *read-base* 10 *read-default-float-format* single-float *read-eval* t *read-suppress* nil *readtable* The standard readtable
Figure 23--1: Values of standard control variables
(with-open-file (file pathname :direction :output)
(with-standard-io-syntax
(print data file)))
;;; ... Later, in another Lisp:
(with-open-file (file pathname :direction :input)
(with-standard-io-syntax
(setq data (read file))))
a radix.
10.
Controls the interpretation of tokens by read as being integers or ratios.
The value of *read-base*, called the current input base @IGindex{current input base} , is the radix in which integers and ratios are to be read by the Lisp reader. The parsing of other numeric types (e.g., floats) is not affected by this option.
The effect of *read-base* on the reading of any particular rational number can be locally overridden by explicit use of the #O, #X, #B, or #nR syntax or by a trailing decimal point.
(dotimes (i 6)
(let ((*read-base* (+ 10. i)))
(let ((object (read-from-string "(\\DAD DAD |BEE| BEE 123. 123)")))
(print (list *read-base* object)))))
|> (10 (DAD DAD BEE BEE 123 123))
|> (11 (DAD DAD BEE BEE 123 146))
|> (12 (DAD DAD BEE BEE 123 171))
|> (13 (DAD DAD BEE BEE 123 198))
|> (14 (DAD 2701 BEE BEE 123 227))
|> (15 (DAD 3088 BEE 2699 123 258))
=> NIL
Altering the input radix can be useful when reading data files in special formats.
one of the atomic type specifiers short-float, single-float, double-float, or long-float, or else some other type specifier defined by the implementation to be acceptable.
The symbol single-float.
Controls the floating-point format that is to be used when reading a floating-point number that has no exponent marker or that has e or E for an exponent marker. Other exponent markers explicitly prescribe the floating-point format to be used.
The printer uses *read-default-float-format* to guide the choice of exponent markers when printing floating-point numbers.
(let ((*read-default-float-format* 'double-float)) (read-from-string "(1.0 1.0e0 1.0s0 1.0f0 1.0d0 1.0L0)")) => (1.0 1.0 1.0 1.0 1.0 1.0) ;Implementation has float format F. => (1.0 1.0 1.0s0 1.0 1.0 1.0) ;Implementation has float formats S and F. => (1.0d0 1.0d0 1.0 1.0 1.0d0 1.0d0) ;Implementation has float formats F and D. => (1.0d0 1.0d0 1.0s0 1.0 1.0d0 1.0d0) ;Implementation has float formats S, F, D. => (1.0d0 1.0d0 1.0 1.0 1.0d0 1.0L0) ;Implementation has float formats F, D, L. => (1.0d0 1.0d0 1.0s0 1.0 1.0d0 1.0L0) ;Implementation has formats S, F, D, L.
a generalized boolean.
true.
If it is true, the #. reader macro has its normal effect. Otherwise, that reader macro signals an error of type reader-error.
*print-readably*
If *read-eval* is false and *print-readably* is true, any method for print-object that would output a reference to the #. reader macro either outputs something different or signals an error of type print-not-readable.
a generalized boolean.
false.
This 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.
If it is false, the Lisp reader operates normally.
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 macro_2 that is defined to read_2 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).
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.
(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)
@xref{read; read-preserving-whitespace} , {section Syntax}
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.
a readtable.
A readtable that conforms to the description of Common Lisp syntax in section Syntax.
The value of *readtable* is called the current readtable. It controls the parsing behavior of the Lisp reader, and can also influence the Lisp printer (e.g., see the function readtable-case).
(readtablep *readtable*) => true (setq zvar 123) => 123 (set-syntax-from-char #\z #\' (setq table2 (copy-readtable))) => T zvar => 123 (setq *readtable* table2) => #<READTABLE> zvar => VAR (setq *readtable* (copy-readtable nil)) => #<READTABLE> zvar => 123
compile-file, load
section compile-file [Function] , section load [Function] , section readtable [System Class] , section The Current Readtable
reader-error, parse-error, stream-error, error, serious-condition, condition, t
The type reader-error consists of error conditions that are related to tokenization and parsing done by the Lisp reader.
@xref{read; read-preserving-whitespace} , section stream-error-stream [Function] , section Reader Concepts
Go to the first, previous, next, last section, table of contents.