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? See reader questions & answers on this topic! - Help others by sharing your knowledge 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. User Contributions: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 March 27 2014 @ 02:11 PM
|
Comment about this article, ask questions, or add new information about this topic: