<p>Just remember that putting a use of call/cc in a context changes the meaning of that use...</p>
<p><blockquote>On Jan 17, 2009 2:22 PM, "Jon Rafkind" <<a href="mailto:rafkind@cs.utah.edu">rafkind@cs.utah.edu</a>> wrote:<br><br><p><font color="#500050">Henk Boom wrote:
>
> 2009/1/17 Jos Koot <<a href="mailto:jos.koot@telefonica.net">jos.koot@telefonica.net</a>>:
>
>>
>> Is that a quation or ju...</font></p>
I think I figured out at least part of it. Hope I don't spoil it for others..<br>
<br>
(let ([f (call/cc1 call/cc2)])<br>
(printf "f is ~a\n" f)<br>
(f (lambda (x) (printf "x is ~a\n" x))))<br>
<br>
I wrote call/cc1 and call/cc2 to mean call/cc but so I could identify them in the explanation. The result of this prints<br>
<br>
f is #<continuation><br>
f is #<procedure:/home/jon/tmp/x.ss:17:5><br>
x is #<procedure:/home/jon/tmp/x.ss:17:5><br>
<br>
The flow is this: call/cc1 passes its continuation to call/cc2 which invokes the first continuation with the second. So f is now equal to the continuation of call/cc2 and it prints #<continuation> as expected. Now f is invoked with the continuation of call/cc2 with (lambda (x) ...) which starts the computation at (let ([f ...]) ...) so f is now bound to (lambda (x) ...). Printing this results in <procedure>, and then the f [which is now (lambda (x) ...)] is applied to (lambda (x) ...) which prints #<procedure> again.<br>
<br>
So at the end it does ((lambda (x) (printf "x is ~a\n" x)) (lambda (x) (printf "x is ~a\n" x))). Maybe this is obvious to some people but it took me at least 15 minutes to figure out.<p><font color="#500050">
_________________________________________________
For list-related administrative tasks:
<a href="http://l.">http://l.</a>..</font></p></blockquote></p>