[racket] Example of using a struct as a port

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Apr 25 19:58:12 EDT 2012

At Sat, 21 Apr 2012 15:32:15 -0400, Chad Albers wrote:
> Otherwise, I
> just don't understand what the use-case is for adding the port property to
> the struct.  Might as well just assign one of the struct's fields to be a
> port, rather than the ceremony of setting a property on the struct.

Occasionally, you have to provide a port to some library or callback,
and when you eventually get a port back, you want to recognize the port
as one that you created. For example, `open-output-string' produces an
output port, but `get-output-string' needs to recognize exactly those
ports that are produced by `open-output-string' so that it can extract
an accumulated string.

That use case is not common, however, and as you have sorted out,
`prop:input-port' and `prop:output-port' are not substitutes for
`make-input-port' and `make-output-port'.

Posted on the users mailing list.