Practical Common Lisp第25页,解释了WITH-STANDARD-IO-SYNTAX,如下所示。 “它确保将影响PRINT行为的某些变量设置为其标准值”。
用法如下。
(with-open-file (...)
(with-standard-io-syntax
(print ...
应该(打印)在这个宏中使用吗?如果没有,会发生什么?
答案 0 :(得分:7)
各种动态变量会影响print
产生的输出。 with-standard-io-syntax
确保将这些变量设置为默认值。
例如:
(let ((list '(1 2 3 4 5 6 7 8 9 10))
(*print-length* 5))
(print list)
(with-standard-io-syntax
(print list)))
打印:
(1 2 3 4 5 ...)
(1 2 3 4 5 6 7 8 9 10)
如果您要打印的内容是为了能够以后read
(与prin1
一样),这一点尤为重要。