[plt-scheme] read, read-line

From: Chongkai Zhu (u0476504 at utah.edu)
Date: Fri Jan 13 17:05:00 EST 2006

======= At 2006-01-13, 12:22:06 Eli Barzilay wrote: =======

>On Jan 13, Chongkai Zhu wrote:
>> I have a program that occasionally needs user input. It 
>> use (read) to get a S-exp and (read-line) to get a string.
>> In v20x, all things work fine.
>
>I don't see any difference between 20x and 30x in the treatment of
>newlines.

Just run

(read)
(read-line)

in both v20x and v30x and you will see the difference.

>
>> Now I shift to v30x. After a (read), normally a #\newline 
>> will be left on the input-port. So the next (read-line) 
>> will get a null string. I can solve by (peek-char) and 
>> then (read-char) if it is #\newline. But will it be more 
>> reasonable if PLT change the (read) to do this auto-
>> matically?
>
>Why?  I would expect `read' to do just what it's supposed to do: read
>an s-expression and not eat away any following whitespace, either
>newline or space.
>
>-- 
>          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                  http://www.barzilay.org/                 Maze is Life!

Sincerely,
Chongkai Zhu  




Posted on the users mailing list.