[plt-scheme] changing the behavior of 'read'?

From: Aaron Leung (akhleung at earthlink.net)
Date: Sun May 25 20:09:06 EDT 2003

Hi Matthew,

I'll try your suggestion.  It looks much simpler, and should suit my 
needs.  Thanks.

--Aaron


On Sunday, May 25, 2003, at 10:10  AM, Matthew Flatt wrote:

> Probably you don't need a custom input port. If you want to transform
> one text stream into another, create a pipe with `make-pipe', and
> create a thread to pump characters from the original port to the write
> side of the pipe.
>
>> (let-values ([(r w) (make-pipe)]
>                 [(orig) (current-input-port)])
>      (thread (lambda ()
>                (let loop ()
>                  (write-char (char-downcase (read-char orig)) w)
>                  (loop))))
>      (current-input-port r))
>
>> "Hello"
>  "hello"
>
> I'm not sure that's the best way to accomplish your task, but it avoids
> custom ports.
>
> Matthew
>



Posted on the users mailing list.