[plt-scheme] Fun with Unicode and delimited continuations

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Jun 3 22:22:41 EDT 2010

On Jun 3, 2010, at 7:47 PM, John Clements wrote:

> 
> On Jun 3, 2010, at 4:33 PM, Matthias Felleisen wrote:
> 
>> 
>> Can you return them from the function that grabs them (in Python)? 
>> Can you resume the function once it has transfered control somewhere else? 
>> Can you store the continuations in some vector? 
>> 
>> (I don't know the answers, but these are some of the things one can do with 1st-class values.) 
> 
> Yes:
> 
> def grabK () : yield 1 ; print "running..." ; yield 2
> 
> def grabAFewKonts () :
>    return [grabK () , grabK ()]
> 
> a = grabAFewKonts();
> 
> f = a[0];
> g = a[1];
> 
> print(f.next());
> print(f.next());
> print(g.next());


Interesting perception. What you are storing are not the continuations but the suspended generators. (Think of grabK() as the creation of a generator.) You could do that in Simula 67, and what you need for that is a pair of control stacks, not a continuation tree. 

So here is the next question then: 

Can you invoke them a __second__ time and get an error message about a second use? 
If you can't, they aren't real one-shot continuations. To be precise, you have no 
observation to prove that they are continuations. 

In the days of denotational semantics, you might have said that you can denote them but not express them (or backwards, Mitch would know). 

-- Matthias







Posted on the users mailing list.