[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] valid implementation of call-with-input-file?



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/20/2012 11:33 AM, Andy Wingo wrote:
> Hi,
>
> Briefly, as I'd like to be to-the-point regarding WG1's work:
> call-with-input-file is not a good abstraction, because it can easily
> leaks FDs on exceptional exit, and is prevented from doing something
> more sensible.
>
> I want them both, but given a choice I would rather have a useful
> call-with-input-file (etc) than raise-continuable, in the small r7rs.

But if we omit raise-continuable, people can still make their own. What
if somebody writes a coroutine library using call/cc and one of the
coroutines uses call-with-input-file, as coroutines are often used for
producer/consumer relationships and files make good producers of input
data? Making call-with-input-file close FDs on all forms of exit will
break that instantly, while leaking FDs until a future garbage
collection cycle will at least only MAYBE fail EVENTUALLY :-)

There might be a middle ground with call-with-input-file where one
closes the FD on exit but replaces it with a (path, offset) pair so it
can be re-opened and re-seeked on re-entry, which then just trades off
breaking access to special files, which is at least a much smaller
issue... But still ugly!

> Andy

ABS

- --
Alaric Snell-Pym
http://www.snell-pym.org.uk/alaric/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlAyFwAACgkQRgz/WHNxCGpaGACfXiA2zJYbpA+1TFpjbFzaaq0m
GAwAnRCvtszhK6wCmLSp2S4+ggwv/t9I
=4KRh
-----END PGP SIGNATURE-----

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports