Arc Forumnew | comments | leaders | submitlogin
on-err simplification
1 point by CatDancer 5991 days ago | discuss
on-err in arc2/ac.scm currently reads:

  (define (on-err errfn f)
    ((call-with-current-continuation
       (lambda (k)
         (lambda ()
           (with-handlers ((exn:fail? (lambda (c)
                                        (k (lambda () (errfn c))))))
                          (f)))))))
no need for the continuation, when an exception occurs, with-handlers returns the return value of the handler. Thus this does the same thing:

  (define (on-err errfn f)
    (with-handlers ((exn:fail? errfn))
                   (f)))