sbcl vs clisp

Discussion of Common Lisp
Post Reply
igro
Posts: 2
Joined: Sun Nov 21, 2010 1:31 pm

sbcl vs clisp

Post by igro » Sun Nov 21, 2010 2:02 pm

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

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

Re: sbcl vs clisp

Post by ramarren » Sun Nov 21, 2010 2:27 pm

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.

igro
Posts: 2
Joined: Sun Nov 21, 2010 1:31 pm

Re: sbcl vs clisp

Post by igro » Sun Nov 21, 2010 5:04 pm

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 :)

Post Reply