Marc Feeley feeley@iro.umontreal.ca writes:
On 24-Apr-08, at 10:47 AM, Joel J. Adamson wrote:
How the heck do I use read-line in a program?
[...]
and I always just end up redefining read-line:
(define (read-this)
(let ((input (read-char)) (output "")) (if (char=? input #\newline) output (string-append (string input) (read-this)))))
(read-this)
""
(read-this)this is text, baby
"this is text, baby"
I'm really not getting this; can someone please explain it to me?
I don't understand the problem you are having! Your read-this is behaving exactly like read-line !
Yeah, it's the same. I was saying my frustration --- and this is monumental because it's the only major frustration I've had in two years of working with Scheme --- was that all I could come up with was a re-implementation of read-line.
The problem is really that I want read-line to behave exactly like (read) except for the form in which it accepts the input: wait for input and accept that input as a string. I could have the user input a line in double-quotes and just use (read), but I would prefer the user not to type the quote marks. Am I being too picky...? The other problem with using a recursive reading-by-token procedure is that the user then has to use ^D to end the line (I've reserved ^D to exit the program).
Joel