Reading a line from *query-io* two makes the next read-line return an empty string. Tested under cmucl/sbcl-mt with sigio/spawn.
(defun foo () (list (read-line *query-io*) (read-line *query-io*) (read-line *query-io*)))
CL-USER> (foo) 1 2 ("1" "" "2")
Gabor
Gabor Melis mega@hotpop.com writes:
Reading a line from *query-io* two makes the next read-line return an empty string. Tested under cmucl/sbcl-mt with sigio/spawn.
...
CL-USER> (foo) 1 2 ("1" "" "2")
Gabor
I've run into a possibly similar problem with the slime repl for code that has a (read-line) following a (read). I'm running cmucl (April snapshot) with emacs 2.3.1. I'm using the CVS tarball of the 15th, and I've had the problem for at least a couple of weeks but I didn't report it because I thought I was doing something wrong in the more complex queries of my real program.
The following stripped-down example runs okay with an empty (read-line) -- labeled as a hack in the listing. The original code runs properly in a terminal or under inferior-lisp-mode without slime.
;; ------- code follows (defvar value "") (defvar number "")
(format t "Enter a number: ") (setf number (read))
;;; **** HACK (when (find-package "SWANK-LOADER") (read-line))
(format t "Enter a string: ") (setf value (read-line))
(format t "NUMBER is now: ~A~%" number) (format t "VALUE is now: ~A~%" value)
;; ------- end of code
;; ------- output with the hack commented out
CL-USER> (load #P"/home/loydf/pinfo/librarian/junk.lisp") ; Loading #p"/home/loydf/pinfo/librarian/junk.lisp". Enter a number: 3 Enter a string: NUMBER is now: 3 VALUE is now: T
;; ------- end of output
I get no chance to enter an answer to the second real query. Similar code with a (read) following a (read-line) seems to run okay.
The list's been very quiet and I need this badly, so here it goes. I'm not sure it is the right fix. The (concat input "\n") thing in slime-repl-send-input unconditionally appends a \n to the input, maybe it should just ensure there is one.
CL-USER> (list (read-line) (read-line)) 1 2 ("1" "2") CL-USER>
Gabor Melis mega@hotpop.com writes:
The list's been very quiet and I need this badly, so here it goes. I'm not sure it is the right fix. The (concat input "\n") thing in slime-repl-send-input unconditionally appends a \n to the input, maybe it should just ensure there is one.
The fix looks good. There was some confusion about when to add an newline. Should be fixed in CVS HEAD.
Thanks for the report.
Helmut.