I can't find out how to do this. In previous implementations read-line
was available but for some reason it isn't in Chez.
How do I just read a line of input?
Chez Scheme is the R6RS implementation.
Use the R6RS get-line
instead of the R7RS read-line
.
I have a read-line in my Standard Prelude; it handles end-of-line as carriage-return, line-feed, or both in either order:
(define (read-line . port)
(define (eat p c)
(if (and (not (eof-object? (peek-char p)))
(char=? (peek-char p) c))
(read-char p)))
(let ((p (if (null? port) (current-input-port) (car port))))
(let loop ((c (read-char p)) (line '()))
(cond ((eof-object? c) (if (null? line) c (list->string (reverse line))))
((char=? #\newline c) (eat p #\return) (list->string (reverse line)))
((char=? #\return c) (eat p #\newline) (list->string (reverse line)))
(else (loop (read-char p) (cons c line)))))))