[plt-scheme] Fun with Unicode and delimited continuations

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Fri Jun 4 13:32:41 EDT 2010

On Fri, Jun 4, 2010 at 1:17 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>
> On Jun 4, 2010, at 1:07 PM, John Clements wrote:
>
>> so I'm not sure I'm understanding what you're suggesting.
>
>
> Here is what I am suggestion:
>
> Welcome to Racket v5.0.0.1.
>> (define f 0)
>> (require racket/control)
>> (+ 1 (let/ec k (set! f k) 10))
> 11
>> f
> #<escape-continuation>
>> (f 1)
> continuation application: attempt to jump into an escape continuation
>
>
> Produce this behavior in Python. In Python, you actually return from the
> procedure (at least it makes it look like it) and you use the continuation,
> yet, you can jump back into
> it.

Generators in Python are not escape continuations, which is what
you're using here.  They're one-shot continuations, which is something
we don't (straightforwardly) have in Racket.  This means they can only
be called once, but can be called from any dynamic context, even
outside the context in which they're captured.
-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.