[ Usenet FAQs | Web FAQs | Documents | RFC Index ]
Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page
Top Document: FAQ: Lisp Frequently Asked Questions 3/7 [Monthly posting]
Previous Document: [3-4] After I NREVERSE a list, it's only one element long. After I SORT a list, it's missing things. What happened?
Next Document: [3-6] I typed a form to the read-eval-print loop, but nothing happened. Why?
-
Search the FAQ Archives
Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page
Top Document: FAQ: Lisp Frequently Asked Questions 3/7 [Monthly posting]
Previous Document: [3-4] After I NREVERSE a list, it's only one element long. After I SORT a list, it's missing things. What happened?
Next Document: [3-6] I typed a form to the read-eval-print loop, but nothing happened. Why?
[3-5] Why does (READ-LINE) return "" immediately instead of waiting for me to type a line?
Many Lisp implementations on line-buffered systems do not discard the newline that the user must type after the last right parenthesis in order for the line to be transmitted from the OS to Lisp. Lisp's READ function returns immediately after seeing the matching ")" in the stream. When READLINE is called, it sees the next character in the stream, which is a newline, so it returns an empty line. If you were to type "(read-line)This is a test" the result would be "This is a test". The simplest solution is to use (PROGN (CLEAR-INPUT) (READ-LINE)). This discards the buffered newline before reading the input. However, it would also discard any other buffered input, as in the "This is a test" example above; some implementation also flush the OS's input buffers, so typeahead might be thrown away.
Top Document: FAQ: Lisp Frequently Asked Questions 3/7 [Monthly posting]
Previous Document: [3-4] After I NREVERSE a list, it's only one element long. After I SORT a list, it's missing things. What happened?
Next Document: [3-6] I typed a form to the read-eval-print loop, but nothing happened. Why?
Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page
[ Usenet FAQs | Web FAQs | Documents | RFC Index ]
Send corrections/additions to the FAQ Maintainer:
ai+lisp-faq@cs.cmu.edu
Last Update October 22 2009 @ 05:26 AM