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

Re: [Scheme-reports] 6.11 Exceptions



On Wed, Jan 9, 2013 at 5:05 PM, Andy Wingo <wingo@x> wrote:
On Wed 09 Jan 2013 03:07, Alex Shinn <alexshinn@x> writes:

>     Secondly, its presence prohibits useful behaviors.  For example, it
>     would be easy to make a `call-with-port' that closes its port on
>     exceptional exits by installing a throw handler.  However, since
>     throw
>     handlers are also used for raise-continuable, this is not possible.
>
> Releasing resources can be done manually at the programmer
> level with their own exception handlers, even wrapping common
> patterns such as `call-with-port/close-on-exception'.

My point is precisely that you cannot implement this behavior when
raise-continuable follows the same dispatch as raise.

Indeed, but my point is don't throw the baby out with the
bathwater.  There will be idioms where you don't want to
support continuable exceptions (perhaps your entire codebase
in fact).  But please don't forbid Schemers who do want to
use them in their own code from doing so.

> Guardians also allow for easy and arbitrary finalization.

Please.  Relying on GC to run (and thus adding ports to guardians) is
not a solution in cases of limited resources like file descriptors.

I disagree - all resources, including memory, are limited, and your
argument sounds to me like the same reason some people argue that
reference counting is superior to GC.

I also think file descriptors are an especially bad example because
they're not very limited, and it's easy to GC them properly.  In chibi

  (do () (#f) (open-input-file "/etc/passwd"))

gracefully loops forever.

There are some situations where you really do want to release a
resource ASAP on error, such as database connections.  In these
cases you can use an idiom to close on error, and yes, this will
not work with continuable exceptions.  That doesn't mean we need
to cripple Scheme by forbidding continuable exceptions altogether.

We can have the best of both worlds.

-- 
Alex

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