Arc Forumnew | comments | leaders | submitlogin
What was desired for on-err?
2 points by CatDancer 6121 days ago | 4 comments
from ac.scm:

  ; If an err occurs in an on-err expr, no val is returned and code
  ; after it doesn't get executed.  Not quite what I had in mind.

  (define (on-err errfn f)
    ((call-with-current-continuation 
       (lambda (k) 
         (lambda () 
           (with-handlers ((exn:fail? (lambda (c) 
                                        (k (lambda () (errfn c)))))) 
                          (f)))))))
  (xdef 'on-err on-err)
I didn't follow the comment... what was the desired behavior?

  arc> (on-err (fn (c) 'oops) (fn () (do1 (/ 8 4) (prn "here"))))
  here
  2
  arc> (on-err (fn (c) 'oops) (fn () (do1 (/ 8 0) (prn "here"))))
  oops
  arc>


1 point by almkglor 6121 days ago | link

  arc> (on-err (fn (c) 'oops) (fn () (do1 (/ 8 0) (prn "here"))))
  here
  oops
Probably?

-----

1 point by bogomipz 6120 days ago | link

Since the division fails, do1 never gets to execute the prn. Both results shown in the original post seem right to me.

-----

1 point by almkglor 6120 days ago | link

The comment specifically bemoans that the code after the error isn't executed - and that this particular fact isn't, exactly, what pg/rtm intended.

-----

1 point by randallsquared 6119 days ago | link

Yeah, I think the only scenario that makes sense is that on-err was supposed to do a CL-like restart without any actual condition system.

-----