Peter E. Midford <firstname.lastname@example.org.EDU> wrote:
| The only system I have found that has a non-blocking char-ready? is
| MacGambit. I've tried Macintosh ports of SCM and Gambit-C on both Unix
| (NetBSD 1.2) and Windows. Is this really a problem with the C run time
| library these implementations are using?
Probably so. On the Unix versions of SCM & MzScheme compiled for Irix,
"char-ready?" is indeed non-blocking. That is, the following program
keeps looping until I type a line-feed -- it doesn't block:
> (define (print . rest) (map display rest) (newline))
> (define (busy)
(read-char) ;eat the line-feed that's waiting
(let loop ((i 0))
(print "after looping " i " times, read: '" (read-line) #\'))
(else (loop (+ i 1))))))
after looping 45871 times, read: 'xyz'
p.s. Note that this is still using "line mode" terminal input, but that's
a property of the terminal driver, not Scheme. To have it wait for a single
charactor only, you'll have to do some system-dependent tweaking of the
terminal modes (e.g., "stty -icanon" or "stty cbreak" or "stty raw", etc.).
Rob Warnock, 7L-551 email@example.com
Silicon Graphics, Inc. http://reality.sgi.com/rpw3/
2011 N. Shoreline Blvd. Phone: 415-933-1673 FAX: 415-933-0979
Mountain View, CA 94043 PP-ASEL-IA