I'm reading the book Practical Common Lisp and there is a piece of code, and I'm using the Clozure CL implementation:
(defun prompt-read (prompt)
(format *query-io* "~a:" prompt)
(force-output *query-io*)
(read-line *query-io*))
After I successfully defined the function, I called it by
(prompt-read "Hello")
And then input "hello" and pressed the enter key, the output is like:
CL-USER> (prompt-read "Hello")
Hello:hello
"hello"
NIL
an additional blank line is added, I tried the code below and there is no additional newline:
(defun test-read ()
(read-line *query-io*))
And then executed it, the result is like:
CL-USER> (test-read)
hello
"hello"
NIL
This time no additional blank line is produced, actually I find that every time read-line follows a format function, a blank line is produced. I tried the code in Clisp implementation and neither case produces a blank line, I just want to know why the blank line appears, and another question is does read-line return two values? Because I see a NIL following the string I input every time, what does this NIL mean?
Thanks for any help!
read-line
. – Barmar