Re: [Scheme-reports] 6.1 Exceptions needs examples Helmut Eller (21 Mar 2012 06:51 UTC)
Re: [Scheme-reports] 6.1 Exceptions needs examples Aaron W. Hsu (21 Mar 2012 19:46 UTC)
Re: [Scheme-reports] 6.1 Exceptions needs examples John Cowan (21 Mar 2012 20:12 UTC)
Re: [Scheme-reports] 6.1 Exceptions needs examples Helmut Eller (22 Mar 2012 08:27 UTC)
Re: [Scheme-reports] 6.1 Exceptions needs examples Andy Wingo (22 Mar 2012 13:28 UTC)
(missing)
Re: [Scheme-reports] 6.1 Exceptions needs examples Helmut Eller (22 Mar 2012 16:36 UTC)
Re: [Scheme-reports] 6.1 Exceptions needs examples Aaron W. Hsu (22 Mar 2012 17:10 UTC)
Re: [Scheme-reports] 6.1 Exceptions needs examples Helmut Eller (22 Mar 2012 18:09 UTC)
Re: [Scheme-reports] 6.1 Exceptions needs examples Andy Wingo (22 Mar 2012 18:22 UTC)
Re: [Scheme-reports] 6.1 Exceptions needs examples John Cowan (22 Mar 2012 23:30 UTC)
Re: [Scheme-reports] 6.1 Exceptions needs examples Helmut Eller (23 Mar 2012 06:11 UTC)
Re: [Scheme-reports] 6.1 Exceptions needs examples John Cowan (23 Mar 2012 06:22 UTC)
Re: [Scheme-reports] 6.1 Exceptions needs examples Helmut Eller (21 Mar 2012 22:40 UTC)

Re: [Scheme-reports] 6.1 Exceptions needs examples Helmut Eller 21 Mar 2012 06:49 UTC

The following message is a courtesy copy of an article
that has been posted to gmane.lisp.scheme.reports as well.

* John Cowan [2012-03-21 03:28] writes:

> Per Bothner scripsit:
>
>> In an implementation like Kawa without full call/cc support
>> it should still be possible to support "normal" non-continuable
>> exception handling, hopefully in a way that makes use of and
>> integrates with native JVM exceptions.
>
> I've been thinking about this off and on for some time.  Here are my
> current ideas.
>
> First, a `parameterize` expression has to compile to a try-finally so that
> when the thunk terminates, the parameter will be reset.
>
> A hidden stack (Java or Scheme, doesn't matter) needs to exist which
> holds the handlers.  A `with-exception-handler` call pushes the handler
> itself on the stack, whereas a `guard` expression just pushes a marker
> of some sort.  Again, a try-finally is needed to clean up the stack as
> control exits through it.
>
> On a call to either `raise` or `raise-continuable` the stack is popped.
> If it's a procedure object, apply it to the condition object passed.
> If that returns, either re-raise or return to the caller as the case
> may be.  But if the object on the stack was a marker, wrap the condition
> object in a Java RuntimeException and throw it.  A `guard` expression is
> compiled into a try-catch structure, so it will intercept it.  Likewise,
> `with-exception-handler` catches any RuntimeException and invokes the
> thunk on it.
>
> I hope this makes sense.

What should this example return

(let ((events '()))
   (guard (c
           (#t #f))
     (guard (c
             ((dynamic-wind
                  (lambda () (set! events (cons 'c events)))
                  (lambda () #f)
                  (lambda () (set! events (cons 'd events))))
              #f))
       (dynamic-wind
           (lambda () (set! events (cons 'a events)))
           (lambda () (raise 'error))
           (lambda () (set! events (cons 'b events))))))
   (reverse events))

Is it '(a b c d a b) or '(a c d b) or '(a b c d) or unspecified?

Helmut

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