我正在从书中删除示例: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]>
答案 0 :(得分:2)
之后插入force-output
format
user-input
以避免i / o缓冲问题:force-output
通常情况下,在换行或换行之前,实际上没有任何内容打印到设备上
finish-output
或<!DOCTYPE html>
<html>
<head>
<title>highlight.js example</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.7/styles/darkula.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.7/highlight.min.js"></script>
<script>
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<pre><code class="markdown">
# hello world
you can write text [with links](http://example.com) inline or [link references][1].
* one _thing_ has *em*phasis
* two __things__ are **bold**
[1]: http://example.com
---
hello world
===========
> markdown is so cool
so are code segments
1. one thing (yeah!)
2. two thing `i can write code`, and `more` wipee!
</code></pre>
</body>
</html>
。