星期六, 六月 12, 2010

Lisp 提示在read之后才出来

(defun ask-number ()
(format t "Please enter a number. ")
(let ((val (read)))
(if (numberp val)
val
(ask-number))))

(defvar val)
(setf val (ask-number))
(defparameter *s* (open "f:\\temp\\mytest.txt" :direction :output :if-does-not-exist :create :if-exists :append))
(format *s* "your input:~A~%" val)
(close *s*)

原因:
format 需要输出一个新行后,才会刷新,所以,加入~%

(format t "Please enter a number. ~%")