The Practical Common Lisp page 25, explains the WITH-STANDARD-IO-SYNTAX as follows. "It ensures that certain variables that affect the behavior of PRINT are set to their standard values".
The usage is as follows.
(with-open-file (...)
(with-standard-io-syntax
(print ...
Should (print) be used in this macro? If not, what would happen?
Various dynamic variables affect the output produced by print
. with-standard-io-syntax
ensures those variables are set to the default values.
For example:
(let ((list '(1 2 3 4 5 6 7 8 9 10))
(*print-length* 5))
(print list)
(with-standard-io-syntax
(print list)))
Prints:
(1 2 3 4 5 ...)
(1 2 3 4 5 6 7 8 9 10)
It's particularly important if you're printing things with the intention of being able to read
them later (like with prin1
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With