<div dir="ltr"><br><br><div class="gmail_quote">On Sat, Jul 19, 2008 at 4:03 PM, Grant Rettke <<a href="mailto:grettke@acm.org">grettke@acm.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
In a thread that I can't find, </blockquote><div>Check out <a href="http://blog.plt-scheme.org">blog.plt-scheme.org</a> last July and August, and of course this list at the same time.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I'm pretty sure that Matthias posted<br>
some interesting "self modifying code" that looked like this, which I<br>
found on:<br>
<br>
<a href="http://en.wikipedia.org/wiki/Call-with-current-continuation" target="_blank">http://en.wikipedia.org/wiki/Call-with-current-continuation</a><br>
<br>
;; [LISTOF X] -> ( -> X u 'you-fell-off-the-end-off-the-list)<br>
(define (generate-one-element-at-a-time a-list)<br>
;; (-> X u 'you-fell-off-the-end-off-the-list)<br>
;; this is the actual generator, producing one item from a-list at a time<br>
(define (generator)<br>
(call/cc control-state))<br>
;; [CONTINUATION X] -> EMPTY<br>
;; hand the next item from a-list to "return" (or an end-of-list marker)'<br>
(define (control-state return)<br>
(for-each<br>
(lambda (an-element-from-a-list)<br>
(call/cc<br>
(lambda (resume-here)<br>
(set! control-state resume-here)<br>
(return an-element-from-a-list))))<br>
a-list)<br>
(return 'you-fell-off-the-end-off-the-list))<br>
;; time to return the generator<br>
generator)<br>
<br>
(define gen (generate-one-element-at-a-time '(a b c)))<br>
(gen)<br>
(gen)<br>
(gen)<br>
(gen)<br>
<br>
This is another chunk of code that worked fine in v372, and per the<br>
thread [Confusing continuation behavior (a question about)], I suspect<br>
that the code shouldn't have worked, because now it goes into an<br>
endless loop?</blockquote><div><br></div><div>I suspect that what changed is that for each is now looking up 'control-state</div><div>only once, so changing it with set! does nothing. That said, I know almost nothing about</div>
<div>what I am talking about here. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
<br>
I'm migrating all of my collected code snips from 3 to 4, perhaps the<br>
solution is the same as the other thread, but I haven't figured that<br>
one out yet ;).<br>
_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
</blockquote></div><br></div>