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

From: Dimitris Vyzovitis (vyzo at media.mit.edu)
Date: Wed Feb 21 20:25:44 EST 2007

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...

(let lp ((ignore #f)) (sync (handle-evt always-evt lp))
should be (and is) omega.

(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.