Page 1 of 1

sbcl vs clisp

Posted: Sun Nov 21, 2010 2:02 pm
by igro
Hi!
My problem is that the code below behaves differently in sbcl and clisp

Code: Select all

(defun say-hello ()
  (princ "Please type your name:")
  (let ((name (read-line)))
    (princ "Nice to meet you, ")
    (princ name)))
In clisp i'm first prompted with "Please enter your name:"

Code: Select all

[2]> (say-hello)
Please type your name:asd
Nice to meet you, asd 
"asd"
In sbcl, when i run (say-hello) i'm carried over to the next line without any prompt. Then when i enter something things just get weired:

Code: Select all

* (say-hello) 
asd
Please type your name:Nice to meet you, asd 
"asd"
Can someone please explain what is going on?

/Igor

Re: sbcl vs clisp

Posted: Sun Nov 21, 2010 2:27 pm
by ramarren
Output buffering. On your system apparently CLISP output is not buffered, but SBCL output is line buffered, so it happens only when a newline occurs. Use FINISH-OUTPUT to guarantee that output was done and finished before progressing in the program.

Re: sbcl vs clisp

Posted: Sun Nov 21, 2010 5:04 pm
by igro
Ramarren wrote:Output buffering. On your system apparently CLISP output is not buffered, but SBCL output is line buffered, so it happens only when a newline occurs. Use FINISH-OUTPUT to guarantee that output was done and finished before progressing in the program.
Thank you. That helped :)