Matthias' comments led me to a couple of articles at Matt Might's site that have helped me greatly in understanding continuations and escape continuations. (I also experienced several functional programming "aha moments" and improved my understanding of exceptions to boot.)<br>
<br><a href="http://matt.might.net/articles/by-example-continuation-passing-style/">http://matt.might.net/articles/by-example-continuation-passing-style/</a> <br><a href="http://matt.might.net/articles/implementing-exceptions/">http://matt.might.net/articles/implementing-exceptions/</a><br>
<br>Cheers,<br><br>Kieron.<br><br><br><div class="gmail_quote">On Thu, Jul 5, 2012 at 12:06 PM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
1. I don't know where this prose is but it reads rather confusing.<br>
<br>
2. If I were you, I'd use an escape continuation rather than an exception handler here. What you seem to want is flow of control, and let/ec is the right tool then.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
<br>
On Jul 5, 2012, at 9:42 AM, Rüdiger Asche wrote:<br>
<br>
> Hi there,<br>
><br>
> a few of you recommended to implement timeouting reads via sync/timeout. That works neat, but it would be even nicer to combine this w/ exception handling, like so:<br>
><br>
><br>
> ...<br>
> ((readbytetimeout)<br>
> (lambda (port)<br>
> (if (sync/timeout READTIMEOUT inport)<br>
> (read-byte inport)<br>
> (raise "read-byte" #t))))<br>
> ...<br>
> ((readsomething) ..... (readbytetimeout) ......<br>
><br>
><br>
> (letrec ((repl (lambda ()<br>
> (dosomethingthatmustexecuteperiodically)<br>
> (let ((readresult<br>
> (call-with-exception-handler HandlerFn<br>
> (readsomething))))<br>
> (repl)))))<br>
> (repl))<br>
><br>
> Iow, I want the REPL to always be operational but restart from the beginning when the innermost read timeouts so that the periodic computations get their turn.<br>
><br>
> I didn't get this to work though because according to the docs, "If the<br>
> exception handler returns a value when invoked by raise, then raise<br>
> propagates the value to the “previous” exception handler (still in the<br>
> dynamic extent of the call to raise, and under the same barrier, if any)."<br>
><br>
> That is true; I get thrown back out of the entire thing because the default uncaught exception handler is called. What ectually does it mean "IF the<br>
> exception handler..." How is it possible for a function NOT to return a value?<br>
> Any return value including #f and () will propagate the exception to the<br>
> default handler; I simply want to stop it where it is.<br>
><br>
> What do I need to do (or paraphrased: What is the necessary implementation of HandlerFn) in order to get this to work? Or do I need yet another control flow or handling mechanism?<br>
><br>
> Thanks!<br>
><br>
><br>
><br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br>