<br><div class="gmail_quote">On Fri, Jul 11, 2008 at 6:21 AM, Matthew Flatt <<a href="mailto:mflatt@cs.utah.edu">mflatt@cs.utah.edu</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Not in general. Aside from `exn:break', built-in exceptions are raised<br>
in a non-continuable way.<br>
<div class="Ih2E3d"></div></blockquote><div><br>Just curious - what are the main reasons behind the exception design to make them non-continuable by default? Is it due to performance or that continuations shouldn't be used at low level exceptions? (is contination the basis for flow controls as scheme generally advertises?)<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">In this specific case, you could adjust the compilation of top-level<br>
variable access by defining `#%top'. Here's one way:<br>
<br>
> (define (handle-undefined exn)<br>
(abort-current-continuation<br>
(default-continuation-prompt-tag)<br>
(lambda () (letrec ([x x]) x))))<br>
> (require (only-in scheme/base [#%top orig-top]))<br>
> (define-syntax-rule (#%top . id)<br>
(call-with-continuation-prompt<br>
(lambda ()<br>
(call-with-exception-handler<br>
(orig-top . handle-undefined)<br>
(lambda () (orig-top . id))))))<br>
> undef<br>
made-up<br>
> (define def 5)<br>
> def<br>
5<br>
<br>
Installing a prompt and exception handler for every top-level lookup is<br>
expensive, though --- about 50 times as expensive as a normal top-level<br>
lookup (when the variable is defined) in my test.<br>
<div class="Ih2E3d"></div></blockquote><div><br>This is an interesting technique - thanks for sharing. The cost is certainly a concern if every lookup pays for it. <br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
That's not quite the problem. It's more that the exception handler is<br>
required to escape, and also that the exception for an undefined<br>
variable doesn't provide a place to escape back to.<font color="#888888"><br></font></blockquote><div><br>So what are the contination-marks used for? I thought they can be used for invoking continuations. The related concepts (prompts, continuation, escape, etc) continues to escape me even with the manual. If there are some links or pointers on how they are all related and used - it's much appreciated.<br>
<br>Thanks,<br>yc<br><br></div></div>