[racket] buffer mode

From: Richard Mittel (rich.mittel at gmail.com)
Date: Sun Aug 15 15:15:37 EDT 2010

I'm trying to get read-char to read a character as soon as it is typed, but
read-char insists on buffering the input until a carriage return is
entered.  The Racket reference says that the buffer mode is controlled by
file-stream-buffer-mode, but it seems to have no effect.  (More confusingly,
the doc says that line buffering, which I think is the behavior I'm seeing,
is not allowed on input ports.)  Here's the code:

(require (lib "mzlib/etc"))
(file-stream-buffer-mode (current-input-port) 'none)
(define (pushpull)
  (define (helper indent)
    (printf "~aX~n" (make-string indent #\space))
    (helper ((case (read-char)
           ((#\l) add1)
           ((#\j) sub1)
           (else identity)) indent)))
  (helper 0))


Thanks for helping,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100815/2a6f7628/attachment.html>

Posted on the users mailing list.