[plt-scheme] Re: Using PLT Scheme libs elsewhere?

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Mon May 21 06:49:51 EDT 2007

SpinyNorman skrev:
> So when opening a port, you need to save a reference to it, rather
> than just invoking the "open" function to provide a "port" argument
> for a calling function.  That is, rather than
> 
>     (foo (open-input-file "bar"))
> 
> you would need to do
> 
>     (define iport (open-input-file "bar"))
>     (foo iport)
>     (close iport)
> 
> Unless, of course, foo *knows* it is supposed to close the port when
> it is finished.
> 
> Right?  Or is there another way to approach this that would allow the
> composition of these functions?

You can see examples of use of call-with-input-file and other
file related functions at the Scheme Cookbook:

     <http://schemecookbook.org/Cookbook/FileCountLines>

-- 
Jens Axel Søgaard



Posted on the users mailing list.