[racket] Not eof evt...

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Nov 19 13:39:49 EST 2011

At Sat, 19 Nov 2011 12:21:21 -0500, Curtis Dutton wrote:
> I see that there is an eof-evt that goes ready once an input port hits eof.
> 
> I am in need of an event for an input port, that is ready only when a
> non-eof would be read from that port, and is never ready once an eof is hit.
> 
> 
> For some reason, I'm having difficulty composing my own (like say by using
> guard-evt)...
> 
> Does anybody know of a nice way of doing this?

You could use `(regexp-match-evt #rx#"." ...)'. That works on ports
that only contain bytes (not non-byte "special" values), and syncing on
the event actually reads the byte.

If `regexp-match-evt' doesn't work for your purposes, you can construct
a suitable event by spawning a thread that uses a `peek-' function and
posts to a semaphore when a byte is ready. See also the implementation
of `regexp-match-evt' in "collects/mzlib/port.rkt".



Posted on the users mailing list.