Hi list,<br><br>Got a quick question about continuations. Take the following program:<br><br>(define r #f)<br>(define value #f)<br>(define y 2)<br><br>(set! value (+ 1<br> y<br> (call/cc (lambda (k)<br>
(set! r k)<br> 1))))<br><br>(display value)<br>(set! y 7)<br>(r 1)<br>(display value)<br><br>(set! y 2)<br>(set! value (+ 1<br> (call/cc (lambda (k)<br> (set! r k)<br>
1))<br> y))<br><br>(display value)<br>(set! y 7)<br>(r 1)<br>(display value)<br><br>This prints "4449" -- in the first expression, y has already been evaluated when we create the continuation, but in the second it has not so it is re-evaluated each time we call the continuation. However, in the Scheme spec it says that operands are to be evaluated in an unspecified order. Is this at odds with the above continuation behaviour? Is this an accident or does PLT guarantee evaluation order of operands? I couldn't tell from the spec whether any concrete behaviour is mandated for (call/cc) embedded in a larger expression.<br clear="all">
<br>-- <br>James Coglan<br><a href="http://github.com/jcoglan/heist">http://github.com/jcoglan/heist</a><br>