What is the WITH-STANDARD-IO-SYNTAX macro?

Practical General Lisp page 25, explains WITH-STANDARD-IO-SYNTAX as follows. "This ensures that certain variables that affect the behavior of PRINT are set to their standard values."

Usage is as follows.

(with-open-file (...)
    (with-standard-io-syntax
        (print ...

Should (print) be used in this macro? If not, what will happen?

+5
source share
1 answer

Various dynamic variables affect the result created print. with-standard-io-syntaxensures that these variables are set to their default values.

For instance:

(let ((list '(1 2 3 4 5 6 7 8 9 10))
      (*print-length* 5))
  (print list)
  (with-standard-io-syntax
    (print list)))

Print

(1 2 3 4 5 ...) 
(1 2 3 4 5 6 7 8 9 10) 

, , read (, prin1).

+6

All Articles