<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-2080885971644496896.post2698032372224392708..comments</id><updated>2008-04-03T07:19:04.111-04:00</updated><category term='units'/><category term='xml'/><category term='structure properties'/><category term='futures'/><category term='web-server'/><category term='threads'/><category term='racketcon'/><category term='planet'/><category term='documentation'/><category term='contracts'/><category term='matthew'/><category term='keybindings'/><category term='macros'/><category term='continuations'/><category term='serialization'/><category term='drscheme'/><category term='typed-scheme'/><category term='scribble'/><category term='channels'/><category term='delimited continuations'/><category term='check syntax'/><category term='set'/><category term='interview'/><category term='tutorials'/><category term='self-reference'/><category term='script'/><category term='parallelism'/><category term='experience-reports'/><category term='scheme video'/><category term='oopsla'/><category term='release'/><category term='academic'/><category term='papers'/><category term='soft state'/><category term='industrial'/><title type='text'>Comments on The Racket Blog: call/cc and self-modifying code</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.racket-lang.org/feeds/2698032372224392708/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default'/><link rel='alternate' type='text/html' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html'/><author><name>Jens Axel Søgaard</name><uri>http://www.blogger.com/profile/15211030864341077735</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2080885971644496896.post-1851530434787103041</id><published>2008-04-03T07:19:00.000-04:00</published><updated>2008-04-03T07:19:00.000-04:00</updated><title type='text'>This is cute; it took me a minute to understand wh...</title><content type='html'>This is cute; it took me a minute to understand what was going on.   On the other hand,  a few years ago I would have been scratching my head for hours.&lt;BR/&gt;&lt;BR/&gt;One complaint though:  this code holds onto a return continuation longer than necessary, introducing the possibility of memory leaks and/or poor GC performance.&lt;BR/&gt;&lt;BR/&gt;Is there some kind of generic technique for destroying a reference to a continuation "on the way out" as you call it?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/1851530434787103041'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/1851530434787103041'/><link rel='alternate' type='text/html' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html?showComment=1207221540000#c1851530434787103041' title=''/><author><name>Leon Smith</name><uri>http://www.blogger.com/profile/06462854866941248768</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html' ref='tag:blogger.com,1999:blog-2080885971644496896.post-2698032372224392708' source='http://www.blogger.com/feeds/2080885971644496896/posts/default/2698032372224392708' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1560500749'/></entry><entry><id>tag:blogger.com,1999:blog-2080885971644496896.post-8751223865351229888</id><published>2008-01-30T00:40:00.000-05:00</published><updated>2008-01-30T00:40:00.000-05:00</updated><title type='text'>Matthias, sorry to be commenting on such an old bl...</title><content type='html'>Matthias, sorry to be commenting on such an old blog post ;-)&lt;BR/&gt;&lt;BR/&gt;This is a pretty cool example, but I think it would be clearer if the internal defines were desugared into a letrec.  It's very odd to see a function definition mutated from inside the function in the first place, but somehow it seems more natural in a letrec.  More importantly (for me at least), is that I can understand right away what the continuation of the letrec would be, but it's not at all obvious with the internal define -- it looks as though the continuation of the (define (generator) ...) code would continue by defining control-state again.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/8751223865351229888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/8751223865351229888'/><link rel='alternate' type='text/html' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html?showComment=1201671600000#c8751223865351229888' title=''/><author><name>Michael</name><uri>http://www.blogger.com/profile/00221993641853949677</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html' ref='tag:blogger.com,1999:blog-2080885971644496896.post-2698032372224392708' source='http://www.blogger.com/feeds/2080885971644496896/posts/default/2698032372224392708' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1876755196'/></entry><entry><id>tag:blogger.com,1999:blog-2080885971644496896.post-8717960294872729905</id><published>2007-07-29T23:02:00.000-04:00</published><updated>2007-07-29T23:02:00.000-04:00</updated><title type='text'>1. Thanks for pointing out the bug. &lt;br&gt;&lt;br&gt;2. Thi...</title><content type='html'>1. Thanks for pointing out the bug. &lt;BR/&gt;&lt;BR/&gt;2. This (correct) code is a  poem on turning a loop into a generator. It is not serious code. &lt;BR/&gt;&lt;BR/&gt;3. And yes, it is writing code like that many times, which first suggested delimited continuations to me in the fall of 1984; it just took three years to write it up.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/8717960294872729905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/8717960294872729905'/><link rel='alternate' type='text/html' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html?showComment=1185764520000#c8717960294872729905' title=''/><author><name>matthias</name><uri>http://www.blogger.com/profile/00000181081270224360</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://www.ccs.neu.edu/home/matthias/Images/felleisen1.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html' ref='tag:blogger.com,1999:blog-2080885971644496896.post-2698032372224392708' source='http://www.blogger.com/feeds/2080885971644496896/posts/default/2698032372224392708' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-697458640'/></entry><entry><id>tag:blogger.com,1999:blog-2080885971644496896.post-4538852792058377675</id><published>2007-07-29T12:10:00.000-04:00</published><updated>2007-07-29T12:10:00.000-04:00</updated><title type='text'>call/cc is indeed a bad choice if all you're doing...</title><content type='html'>call/cc is indeed a bad choice if all you're doing is making a generator out of a flat list. However, the technique mentioned works about equally well for turning folds over arbitrary data structures into generators/cursors.&lt;BR/&gt;&lt;BR/&gt;For instance, writing a generator for a binary tree using only the analogues to car/cdr is a pain (I imagine you'd manage a stack of nodes to be visited by hand). However, writing an in-order traversal is simple. This example shows that you can turn the latter into the former automatically and generically using call/cc.&lt;BR/&gt;&lt;BR/&gt;Of course, for the particular case of turning a fold into a cursor, delimited continuations are, perhaps, even nicer (and, in a sense, this example might be mimicking delimited continuations with call/cc + state). Something like:&lt;BR/&gt;&lt;BR/&gt;(define (mk-generator traversal structure)&lt;BR/&gt;   (define (generator) (control-loop))&lt;BR/&gt;&lt;BR/&gt;   (define (control-loop)&lt;BR/&gt;      (reset&lt;BR/&gt;         (traversal&lt;BR/&gt;            (lambda (element)&lt;BR/&gt;               (shift&lt;BR/&gt;                  (lambda (k)&lt;BR/&gt;                     (set! control-loop (lambda () (k #f)))&lt;BR/&gt;                     element)))&lt;BR/&gt;            structure)&lt;BR/&gt;         'traversal-done))&lt;BR/&gt;&lt;BR/&gt;   generator)&lt;BR/&gt;&lt;BR/&gt;Which, handily, avoids having to worry about keeping track of a return continuation for this problem.&lt;BR/&gt;&lt;BR/&gt;The problem of turning folds into cursors in various languages, and the advantages of structuring a collection library in such a way are &lt;A HREF="http://okmij.org/ftp/Computation/Continuations.html#enumerator-stream" REL="nofollow"&gt;discussed in more depth here&lt;/A&gt;.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/4538852792058377675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/4538852792058377675'/><link rel='alternate' type='text/html' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html?showComment=1185725400000#c4538852792058377675' title=''/><author><name>Dan Doel</name><uri>http://www.blogger.com/profile/16761291400347369301</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html' ref='tag:blogger.com,1999:blog-2080885971644496896.post-2698032372224392708' source='http://www.blogger.com/feeds/2080885971644496896/posts/default/2698032372224392708' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-279915015'/></entry><entry><id>tag:blogger.com,1999:blog-2080885971644496896.post-1816754561983871300</id><published>2007-07-29T05:29:00.000-04:00</published><updated>2007-07-29T05:29:00.000-04:00</updated><title type='text'>@Gavin: Actually, it is exactly what the recent ca...</title><content type='html'>@Gavin: Actually, it is exactly what the recent call/cc hype was about: To allow implicit (foreach) instead of explicit state machines, esp. in the context of web applications. Imagine the state getting a little bit more complicated. (You'd need to hide the call/cc in an abstraction for the generator programmer as well, though.)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/1816754561983871300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/1816754561983871300'/><link rel='alternate' type='text/html' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html?showComment=1185701340000#c1816754561983871300' title=''/><author><name>Andreas Krey</name><uri>http://www.blogger.com/profile/18011171943440483489</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://images.iocl.org/ak.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html' ref='tag:blogger.com,1999:blog-2080885971644496896.post-2698032372224392708' source='http://www.blogger.com/feeds/2080885971644496896/posts/default/2698032372224392708' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1565035292'/></entry><entry><id>tag:blogger.com,1999:blog-2080885971644496896.post-8957100690563545273</id><published>2007-07-29T00:39:00.000-04:00</published><updated>2007-07-29T00:39:00.000-04:00</updated><title type='text'>this is a terrible misuse of call/cc.&lt;br&gt;here is a...</title><content type='html'>this is a terrible misuse of call/cc.&lt;BR/&gt;here is a better implementation:&lt;BR/&gt;&lt;BR/&gt;(define (one-at-a-time lst)&lt;BR/&gt;  (lambda ()&lt;BR/&gt;    (if (null? lst)&lt;BR/&gt; 'you-fell-off-the-end&lt;BR/&gt; (let ((x (car lst)))&lt;BR/&gt;   (set! lst (cdr lst))&lt;BR/&gt;   x))))</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/8957100690563545273'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/8957100690563545273'/><link rel='alternate' type='text/html' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html?showComment=1185683940000#c8957100690563545273' title=''/><author><name>Gavin</name><uri>http://www.blogger.com/profile/12575866657010241016</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html' ref='tag:blogger.com,1999:blog-2080885971644496896.post-2698032372224392708' source='http://www.blogger.com/feeds/2080885971644496896/posts/default/2698032372224392708' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-6379231'/></entry><entry><id>tag:blogger.com,1999:blog-2080885971644496896.post-1750427370079384670</id><published>2007-07-28T19:37:00.000-04:00</published><updated>2007-07-28T19:37:00.000-04:00</updated><title type='text'>Hello, a quick question:&lt;br&gt;&lt;br&gt;I'm not a scheme g...</title><content type='html'>Hello, a quick question:&lt;BR/&gt;&lt;BR/&gt;I'm not a scheme guru, but the posted code seems a bit off. Specifically, it looks to me like 'return' is only bound the first time generator is called, so if you used it like:&lt;BR/&gt;&lt;BR/&gt;   (generator)&lt;BR/&gt;   ...&lt;BR/&gt;   (generator)&lt;BR/&gt;&lt;BR/&gt;On the second call, it would jump back to the first call (since that's what the continuation stored in 'return' is). It seems like it should instead be something like (totally untested):&lt;BR/&gt;&lt;BR/&gt;  ...&lt;BR/&gt;  (lambda (an-element-from-a-list)&lt;BR/&gt;     (set! return&lt;BR/&gt;           (call/cc&lt;BR/&gt;               (lambda (resume-here)&lt;BR/&gt;                   (set! control-state resume-here)&lt;BR/&gt;                   (return an-element-from-a-list)))))&lt;BR/&gt;  ...&lt;BR/&gt;&lt;BR/&gt;However, as I said, I don't write a lot of scheme, so maybe I'm missing something.&lt;BR/&gt;&lt;BR/&gt;Apologies for the terrible formatting, but I'm not sure how to tell blogger to display stuff as code.&lt;BR/&gt;&lt;BR/&gt;Cheers.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/1750427370079384670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/1750427370079384670'/><link rel='alternate' type='text/html' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html?showComment=1185665820000#c1750427370079384670' title=''/><author><name>Dan Doel</name><uri>http://www.blogger.com/profile/16761291400347369301</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html' ref='tag:blogger.com,1999:blog-2080885971644496896.post-2698032372224392708' source='http://www.blogger.com/feeds/2080885971644496896/posts/default/2698032372224392708' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-279915015'/></entry><entry><id>tag:blogger.com,1999:blog-2080885971644496896.post-8657223809125972670</id><published>2007-07-28T03:29:00.000-04:00</published><updated>2007-07-28T03:29:00.000-04:00</updated><title type='text'>A pretty little ditty, to be sure. Much of object-...</title><content type='html'>A pretty little ditty, to be sure. Much of object-oriented programming relies on self-modifying code, if you think about it. Consider the &lt;I&gt;strategy&lt;/I&gt; pattern or the &lt;I&gt;state&lt;/I&gt; pattern. In object-oriented programs it may appear that we are changing the data, but we are really changing the code.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/8657223809125972670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/8657223809125972670'/><link rel='alternate' type='text/html' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html?showComment=1185607740000#c8657223809125972670' title=''/><author><name>I, Object</name><uri>http://www.blogger.com/profile/06064429394008899781</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://farm1.static.flickr.com/29/42328144_48fda25f88_m.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html' ref='tag:blogger.com,1999:blog-2080885971644496896.post-2698032372224392708' source='http://www.blogger.com/feeds/2080885971644496896/posts/default/2698032372224392708' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2084736790'/></entry><entry><id>tag:blogger.com,1999:blog-2080885971644496896.post-9100747973627969544</id><published>2007-07-28T02:38:00.000-04:00</published><updated>2007-07-28T02:38:00.000-04:00</updated><title type='text'>This is really beautiful. :)</title><content type='html'>This is really beautiful. :)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/9100747973627969544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2080885971644496896/2698032372224392708/comments/default/9100747973627969544'/><link rel='alternate' type='text/html' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html?showComment=1185604680000#c9100747973627969544' title=''/><author><name>Jianshi Huang</name><uri>http://www.blogger.com/profile/01477856503813480062</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.racket-lang.org/2007/07/callcc-and-self-modifying-code.html' ref='tag:blogger.com,1999:blog-2080885971644496896.post-2698032372224392708' source='http://www.blogger.com/feeds/2080885971644496896/posts/default/2698032372224392708' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-648798300'/></entry></feed>
