[plt-scheme] Fun with Unicode and delimited continuations

From: John Clements (clements at brinckerhoff.org)
Date: Thu Jun 3 13:55:34 EDT 2010

On Jun 3, 2010, at 10:40 AM, John Clements wrote:
> 
> 
> Right... the problem with this is that the body of bar gets horribly mangled, and the calls to foo have to be lifted out.  This is basically the partial CPSing that would be required to implement this without generators.
> 
> I'm wondering, though: if you "capture a continuation" by using a yield in Python, and make a copy of the resulting generator, can you enter the two resulting "continuations" separately, or does the copied object contain a reference to state that gets messed up?
> 
> I just spent a few minutes on this, and I got hung up on how to pull just one value from a python generator.  It's probably easy, but I don't know how to do it.
> 

So, Jon told me about the 'next' method.  

Unfortunately, it confirms that the "continuations" you get using 'yield' are one-shot.  In retrospect, this seems entirely obvious.

>>> def generator () :
...   yield 1;
...   yield 2;
... 
>>> newgenerator = generator()
>>> copiedgenerator = newgenerator
>>> newgenerator.next()
1
>>> copiedgenerator.next()
2

Perhaps there's some way to copy a generator's current state?

Anyhow, I'm ready to concede that yield is definitely a different animal than delimited continuations.  Thanks!

John

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4669 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100603/10164b53/attachment.p7s>

Posted on the users mailing list.