[racket] Weird continuation behavior (to me...)

From: Ryan Culpepper (ryan at cs.utah.edu)
Date: Tue Aug 9 13:00:33 EDT 2011

On 08/06/2011 04:28 AM, Stephen Halter wrote:
> Hi everyone,
> I was reading through the wikipedia article on call/cc, and I thought
> that playing around with some of the provided examples in DrRacket would
> give me a better understanding of the feature. The second example was
> how a python style generator could be created using call/cc
> (http://en.wikipedia.org/wiki/Call-with-current-continuation#Examples).
> I was looking how set! was used to update control-state's return
> argument to the continuation referencing the most recent call to the
> generator. I figured that if I removed the set! and called the generator
> twice in a row, it would create an infinite loop of sorts since
> control-state's return argument would forever hold a continuation
> originating from the first call. However, this is not what happens when
> I remove the set!. Instead it works exactly the same way it did before.
> Any ideas why?
> Thanks in advance for your help,
> Stephen Halter
> Below is the code that I where I don't (re)set! control-state's return
> argument:
> https://gist.github.com/1129202

 > (generate-digit)
 > (list (generate-digit) (generate-digit))

Hmmm.... I was expecting '(1 2)


Posted on the users mailing list.