[plt-scheme] handle-evt can wrap handle-evt

From: Robby Findler (robby at cs.uchicago.edu)
Date: Wed Feb 21 21:27:42 EST 2007

No no - you misunderstand. Of course, that is the main technique for
all CML-style programs! Everyone knows that.

When there is a single handle-evts, its proc should be called in tail
position wrt to the sync. But no one is proposing making all of them
in  tail-position wrt to the sync. That's not possible. (Matthew
proposed an error.)

Robby

On 2/21/07, Dimitris Vyzovitis <vyzo at media.mit.edu> wrote:
> On Wed, 21 Feb 2007, Robby Findler wrote:
>
> > I don't see any value in guaranteeing that a handle event's handler
> > function is called in tail position, except in the case that there
> > aren't other handle events in there. And, I think it makes it harder
> > to abstract to disallow this. I can't think of any examples, tho.
>
> I think there is a very good reason: The handler can be a main-loop
> function that processes the event and resyncs. If you don't have that
> guarantee it becomes really hard (and awkward) to write main-loops for
> reactive programs because you lose tail recursion...
>
> Ie:
> (let lp ((ignore #f)) (sync (handle-evt always-evt lp))
> should be (and is) omega.
>
> while
> (let lp ((ignore #f)) (sync (wrap-evt always-evt lp)))
> should (and does) just exhaust the "stack" (run out of memory).
>
>
> -- vyzo
>
>


Posted on the users mailing list.