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

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

Hash: SHA1

On 08/20/2012 02:01 PM, Andy Wingo wrote:
> Hi,
> On Mon 20 Aug 2012 12:52, Alaric Snell-Pym <alaric@x> writes:
>> [I]f we omit raise-continuable, people can still make their own.
> This is a great thing!
>> 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?
> Then the file stays open until a normal or an exceptional return
> happens.  Note that call/cc is neither of these.  (What is an
> exceptional return?  A raise to a guard outside the scope of the
> call-with-input-file.)

Ok, making a whitelist of know types of exit that probably will never
return is reasonably pragmatic, but still prone to user surprises if
they save continuations from within that scope nonetheless. Arguably no
more prone to user surprises than the result of zapping back to a point
in the execution of the code that had a file open without rewinding the
current file pointer or other I/O state, perhaps...

However, WG1 has proven too afraid of innovating and getting it wrong to
suggest anything more than hinting at the implementations to be
Sufficiently Smart about garbage collection of continuations (which is
perhaps the only complete solution to "can this scope ever be
re-entered?" questions). But the fact that a normal exit already closes
the port, and that the implementation knows if a raise is continuable or
not, suggests that it might not be too extreme to choose to consider a
non-continuable raise to count like a normal exit. However, it may be a
bit late now!

> Andy


- --
Alaric Snell-Pym
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/


Scheme-reports mailing list