Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

emacs - slime prints my (format ...) calls only when called function ends

I have emacs + sbcl + slime installed. I have this function defined

(defun jugar ()
  (let* ((nodoActual *nodo-inicial*)
         (estadoActual (nodo-estado nodoActual))
         (timeStart nil)
         (timeEnd nil)
         )
    (loop while (not (es-estado-final estadoActual)) do
          (setf *hojas* 0)
          (setf timeStart (get-universal-time))
          (setf nodoActual (decision-minimax nodoActual *profundidad* timeStart))
          (setf timeEnd (get-universal-time))
          (setf estadoActual (nodo-estado nodoActual))
          (imprime-en-fichero estadoActual)
          (format t "Hojas analizadas:     ~a  ~%" *hojas*)
          (format t "Tiempo empleado:     ~a  ~%~%" time))   
    ))

that makes a series of calls and print some variables in a loop.

The problem is when I call (jugar) from the *slime-repl sbcl* buffer, the prompt waits until (jugar) execution ends for showing all the (format …) together. I tried the same from a terminal (running sbcl) and it works well, so I guess it is something related to emacs or slime. How can I fix it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

proksid's answer mentions force-output, which is on the right track, but there are actually a few related possibilities. The documentation for force-output also describes finish-output (and clear-output, which isn't relevant for us):

finish-output, force-output, and clear-output exercise control over the internal handling of buffered stream output.

finish-output attempts to ensure that any buffered output sent to output-stream has reached its destination, and then returns.

force-output initiates the emptying of any internal buffers but does not wait for completion or acknowledgment to return.

clear-output attempts to abort any outstanding output operation in progress in order to allow as little output as possible to continue to the destination.

If you want to guarantee that the output from the different iterations doesn't get interleaved (I don't know whether this is likely or not), you might want to consider finish-output instead of force-output. In either case, at least be aware of both options.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...