[plt-scheme] Fun with Unicode and delimited continuations

From: Doug Orleans (dougorleans at gmail.com)
Date: Thu Jun 3 09:58:36 EDT 2010

On Thu, Jun 3, 2010 at 9:08 AM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
> On Jun 3, 2010, at 8:55 AM, Eli Barzilay wrote:
>> On Jun  3, Matthias Felleisen wrote:
>>> This must be the most fun (and useless) use of delimited
>>> continuations I have seen since 1984.
>> I'll bite: why is it useless?
> The reset and shift in this case statically determine
> the delimited continuation:
>  \x. (/ x (* 2 a))
> if it were prompt/control.

I had recently read a discussion of delimited continuations in Scala,
which implemented "zip" in a similar manner:


So when I was implementing the quadratic formula for a Project Euler
problem (can you guess which one?  it's in the first 50) I thought I'd
try this approach.  Yes, obviously it's overkill for such a simple
continuation (and it's surprisingly inefficient-- something like 20x
slower than when I had worked out the quadratic roots by hand), but I
thought it was neat to see a Scheme expression that looked as much
like the quadratic formula as I could make it.  (I thought about using
double-dot infix notation but that's just too ugly.)  I think it's
similar to using continuations in the web server, to avoid having to
break up the flow of a procedure that needs to get information from
the user.

> Of course, one can also shift (pardon the pun) reset around
> and start discussions of backtracking computations at this
> point and more stuff like that.

Yes, it's not really clear where to put the reset.  If you have more
computations you want to apply to both roots, then you might want to
move the reset earlier.  This is probably not a useful general-purpose
API, but I wonder if different continuation constructs would help
somehow?  I still don't quite grok all the differences between the
various operators in scheme/control.

--dougorleans at gmail.com

Posted on the users mailing list.