【发布时间】:2015-11-01 20:56:00
【问题描述】:
我正在删除书中的示例:ANSI Common Lisp,第 14.6 章条件。
sbcl 没有以正确的顺序打印提示:
示例代码:
(defun user-input (prompt)
(format t prompt)
(let ((str (read-line)))
(or (ignore-errors (read-from-string str))
nil)))
在sbcl测试中,提示不会按顺序打印:
* (defun user-input (prompt)
(format t prompt)
(let ((str (read-line)))
(or (ignore-errors (read-from-string str))
nil)))
STYLE-WARNING: redefining COMMON-LISP-USER::USER-INPUT in DEFUN
USER-INPUT
* (user-input "Please type an expression> ")
test
Please type an expression>
TEST
* (user-input "Please type an expression> ")
#%@#+!!
Please type an expression>
NIL
*
但在 clisp 中,提示是按顺序打印的,并且按预期工作:
[5]> (defun user-input (prompt)
(format t prompt)
(let ((str (read-line)))
(or (ignore-errors (read-from-string str))
You are in the top-level Read-Eval-Print loop.
Help (abbreviated :h) = this list
Use the usual editing capabilities.
(quit) or (exit) leaves CLISP.
nil)))
USER-INPUT
[6]> (user-input "Please type an expression> ")
Please type an expression> #%@#+!!
NIL
[7]>
【问题讨论】:
-
输出在 SBCL 中缓冲。查看函数 force-output 和 finish-output。
标签: io common-lisp sbcl clisp