2013-11-23 67 views
1

在SLIME中运行此命令,并想知道为什么在输出format之前等待read输入。READ在FORMAT之前运行

(defun wage() 
    (format t "~&Enter wage: ") 
    (let ((wage (read))) 
    (format t "~&Enter hours: ") 
    (let ((hours (read))) 
     (format t "~&Earned ~S dollars." (* wage hours))))) 

* (wage) 

2 
Enter wage: 
3 
Enter hours: 
Earned 6 dollars. 
NIL 
+1

可能重复的[slime打印我的(格式...)调用只有当被调用的函数结束](http://stackoverflow.com/questions/19204332/slime-prints-my-format-calls-only-when-被叫功能部) –

回答

3

发生这种情况是因为标准输出流被缓冲,这意味着打印到它的东西实际上不会立即写入显示屏。您需要在(read)之前在每个实例中调用(finish-output),以确保首先写入缓冲的任何内容。

相关问题