[plt-scheme] Interactive input

From: Gregory Woodhouse (gregory.woodhouse at sbcglobal.net)
Date: Thu Jan 19 08:55:29 EST 2006

I realize this is a basic question, but...

In a naive attempt to write a function that could either accept  
interactive (keyboard) input or read from a file, I tried writing a  
loop that repeatedly called read-line and then tested to see if the  
value was eof-object. In retrospect, it's not terribly surprising  
that it didn't work (presumably, the return value was eof-object when  
no input was ready), but what is the alternative? I can try reading  
input a character at a time, repeatedly using peek-char, but that  
seems ugly and cumbersome. I can write a special reader for input  
that comes from the keyboard, a telnet session, or a similar source,  
and a different one for files on disk, but is that necessary? The  
input will be program text, but not (necessarily) Scheme or Lisp and  
I cannot assume that the input will be in the form of S-expressions.

===
Gregory Woodhouse
gregory.woodhouse at sbcglobal.net

"The universe is not required to be in
perfect harmony with human ambition."
--Carl Sagan




Posted on the users mailing list.