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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; y<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (call/cc (lambda (k)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (set! r k)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (call/cc (lambda (k)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (set! r k)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; y))<br><br>(display value)<br>(set! y 7)<br>(r 1)<br>(display value)<br><br>This prints &quot;4449&quot; -- 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&#39;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>