[gambit-list] with-exception-handler supports recursion?

Mikael mikael.rcv at gmail.com
Sun Mar 31 20:40:44 EDT 2013


Aaha, noted. So the way to stack exception handlers atop of each others are
by continuation-capture as you gave an example of in the previous email,
here applied to this usecase. Thanks for clarifying!


 (with-exception-handler
  (lambda (e)
    (print "Outer.\n")
    'outer-handler-result)
  (lambda ()
    (continuation-capture
     (lambda (cont)
       (with-exception-handler
        (lambda (e)
          (print "Inner.\n")
          (let ((r (continuation-graft cont (lambda () (raise e)))))
            (print "Passing on " r ".\n")
            r))
        (lambda () (list 'raise-returned: (raise 'err))))))))



2013/4/1 Marc Feeley <feeley at iro.umontreal.ca>

>
> On 2013-03-31, at 3:02 PM, Mikael <mikael.rcv at gmail.com> wrote:
>
> > Dear Marc,
> >
> > (with-exception-handler
> >  (lambda (e)
> >    (print "Outer.\n")
> >    'outer-handler-result)
> >  (lambda ()
> >    (with-exception-handler
> >     (lambda (e)
> >       (print "Inner.\n")
> >       (let ((r (raise e)))
> >         (print "Passing on " r ".\n")
> >         r))
> >     (lambda () (list 'raise-returned: (raise 'err))))))
> >
> > prints out "Inner.\n" in an infinite loop currently. Is it not supposed
> to output
> >
> > Inner.
> > Outer.
> > Passing on outer-handled-result.
> >
> > and then return '(raise-returned: outer-handler-result) ?
>
> That's the correct behavior.  Don't confuse with-exception-catcher (which
> corresponds to try/catch in other programming languages) and
> with-exception-handler (which installs an exception handler which will be
> active when the exception handler is called).
>
> Marc
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://webmail.iro.umontreal.ca/pipermail/gambit-list/attachments/20130401/b0093983/attachment.html 


More information about the Gambit-list mailing list