Gregg Arthur Evans
Gregg Arthur Evans

Reputation: 109

lisp read command works wrong for sbcl

I schlocked this example of a read function from (Land of Lisp)in to my sbcl repl and it does not show the prompt: "Please type your name" until after I type in a response. then it shows the response. I know this is wrong what gives?

(defun say-hello ()
    (princ "Please type your name:") (let ((name (read-line)))
             (princ "Nice to meet you, ")
             (princ name)))

I have tried other example write functions and have tried write instead of princ. No luck

here's the cut and paste from my repl:

* (defun say-hello ()
(princ "Please type your name:") (let ((name (read-line)))
         (princ "Nice to meet you, ")
         (princ name)))
WARNING: redefining COMMON-LISP-USER::SAY-HELLO in DEFUN

SAY-HELLO
* (say-hello)
gregg
Please type your name:Nice to meet you, gregg
"gregg"

Upvotes: 0

Views: 242

Answers (1)

user5920214
user5920214

Reputation:

You should call finish-output after the first princ, to ensure that the output has actually been flushed.

Upvotes: 3

Related Questions