[racket] Example of using a struct as a port

From: Chad Albers (calbers at neomantic.com)
Date: Sat Apr 21 11:52:59 EDT 2012

Hi,

I'm looking for an example of treating a struct like a port, which appears
to be possible:
http://docs.racket-lang.org/reference/portstructs.html?q=struct#(def._((quote._~23~25kernel)._prop~3ainput-port))

Apparently, this is a lot easier that using make-custom-port.   What I
would like to do is be able to declare a struct, set it's prop:input-port
property, pass an instance of struct to a port procedure, like (read-bytes
string-that-acts-like-port), and have the bytes sent to the read-bytes
actually contain bytes that were stored in the fields of the struct itself.
 Is that possible, and is that the reason why one would treat a struct like
a port?

Thanks in advance for any examples,
--
Chad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120421/220e84cd/attachment.html>

Posted on the users mailing list.