<div dir="ltr">Ah ha! Thank you Marc for that explanation. It was something so simple all along! I spent a considerable number of hours staring at these few lines today. Sorry for leaping to conclusions regarding the integrity of your code! <div style>
  -Patrick</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 9, 2013 at 8:29 PM, Marc Feeley <span dir="ltr"><<a href="mailto:feeley@iro.umontreal.ca" target="_blank">feeley@iro.umontreal.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Dec 9, 2013, at 11:01 PM, Patrick Li <<a href="mailto:patrickli.2001@gmail.com">patrickli.2001@gmail.com</a>> wrote:<br>
<br>
> However, this leaves me feeling deeply disturbed. I feel that<br>
><br>
> (f (g x))<br>
><br>
> should *always* be absolutely equivalent to:<br>
><br>
> (let [(temp (g x))]<br>
>    (f temp))<br>
><br>
> My example indicates that this is not necessarily the case. Are there other situations where this is not true? I suspect that I don't quite understand the interaction between tail-calls and continuations properly.<br>

<br>
</div>When evaluation is left-to-right (which is not required by the standard, but is common) the expression (f (g x)) is evaluated as though it was<br>
<br>
  (let ((t1 f)) ;; get value of f<br>
    (let ((t2 g)) ;; get value of g<br>
      (let ((t3 x)) ;; get value of x<br>
        (let ((t4 (t2 t3))) ;; call (g x)<br>
          (t1 t4))))) ;; call (f (g x))<br>
<br>
The expression (let ((temp (g x))) (f temp)) forces a different order, namely<br>
<br>
  (let ((t1 g)) ;; get value of g<br>
    (let ((t2 x)) ;; get value of x<br>
      (let ((t3 (t1 t2))) ;; call (g x)<br>
        (let ((t4 f)) ;; get value of f<br>
          (t4 t3))))) ;; call (f temp)<br>
<br>
In your code, this makes a difference because f (which is "return-point" in your code) is being mutated during the evaluation of the call to g.<br>
<br>
In your "version 1", the function originally bound to return-point will be called (i.e. the continuation of the function make-jp).  In your "version 2", the function bound to return-point by the call to (block jp) will be called (i.e. the continuation of the call (y 0)).<br>

<span class="HOEnZb"><font color="#888888"><br>
Marc<br>
<br>
</font></span></blockquote></div><br></div>