Lisp format and force-output

夙愿已清 提交于 2019-11-27 23:40:13

You need to use FINISH-OUTPUT.

In systems with buffered output streams, some output remains in the output buffer until the output buffer is full (then it will be automatically written to the destination) or the output buffer is explicity emptied.

Common Lisp has three functions for that:

  • FINISH-OUTPUT, attempts to ensure that all output is done and THEN returns.

  • FORCE-OUTPUT, starts the remaining output, but IMMEDIATELY returns and does NOT wait for all output being done.

  • CLEAR-OUTPUT, tries to delete any pending output.

Also the T in FORCE-OUTPUT and FORMAT are unfortunately not the same.

  • force-output / finish-output: T is *terminal-io* and NIL is *standard-output*

  • FORMAT: T is *standard-output*

this should work:

(format t "asdf")
(finish-output nil)   ;  note the NIL
(setq var (read))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!