[racket] design and rationale of ports

From: Taylor R Campbell (campbell+racket at mumble.net)
Date: Wed Nov 10 13:38:04 EST 2010

   Date: Wed, 10 Nov 2010 00:12:13 -0800
   From: YC <yinso.chen at gmail.com>

   On Wed, Nov 10, 2010 at 12:00 AM, Taylor R Campbell <campbell+racket at mumble.net <campbell%2Bracket at mumble.net>> wrote:

   > I am completely lost in the documentation and implementation of ports.
   > Is there a document giving a high-level overview of the design of the
   > port abstraction in Racket, and its rationale, ideally with motivating
   > examples of tasks requiring all the various bizarre knobs and buttons
   > of the abstraction (not necessarily all at once, of course)?

   Don't know of any such documentations, but if you have a specific questions
   it might be easier to answer.

The documentation describes the contract of MAKE-INPUT-PORT and
MAKE-OUTPUT-PORT.  That doesn't tell me how the pieces fit together,
though, or say what one can do with them, or give any guidance on how
to make them.  For example, given the pieces of an input port, how do
I implement PEEK-BYTE or READ-BYTE?  Conversely, suppose I have a file
descriptor and some way to do a non-blocking read on it, or an
asynchronous (aio) read on it; how do I make the pieces of an input

(All of this is already implemented in Racket, of course, but it's
implemented in an enormous pile of cpp-conditionalized C that I find
very hard to follow and that doesn't tell me anything about the
abstraction as Scheme sees it.)

Posted on the users mailing list.