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

Re: [Scheme-reports] Fwd: Comments on draft 6 about call/cc



On Tue 21 Feb 2012 02:15, John Cowan <cowan@x> writes:

> An exceptional exit is simply a non-local exit from an exception handler.
> It's not particularly obvious when this is happening.

What's wrong with something like this?

  (define (call-with-input-file filename proc)
    (let ((port (open-input-file filename)))
      (with-exception-handler
        (lambda (x)
          (close-input-port port)
          x)
        (lambda ()
          (call-with-values (lambda () (proc port))
            (lambda vals
              (close-input-port port)
              (apply values vals)))))))

> `Guard` works by capturing its continuation and setting a handler that
> captures the continuation at the point of raise.  The guard continuation
> is then restored, which gives us the outer dynamic environment, and the
> cond-clauses are executed.  If we fall off the end of the cond-clauses,
> the point-of-raise continuation is restored (giving us the inner dynamic
> environment) and the condition object is reraised.

This is expensive (reifying continuations for exceptional control-flow)
and error-prone (giving dynamic-wind workouts, and preventing exception
handling within run-once blocks).

Andy
-- 
http://wingolog.org/

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