<div dir="ltr">I am developing the semantics for a formulation of coroutines that I've been working on. In vague-ish english words, make-jp returns a "callable thing", which I am calling a "jump point". Every time that a "jump point" is called, execution jumps to the last place where the jump-point was invoked. <div>
<br></div><div style>If Bigloo, Chicken, and Gambit all behave the same way then I think you are probably right and that this is proper behavior. </div><div style><br></div><div style>However, this leaves me feeling deeply disturbed. I feel that </div>
<div style><br></div><div style>(f (g x))</div><div style><br></div><div style>should *always* be absolutely equivalent to:</div><div style><br></div><div style>(let [(temp (g x))]</div><div style>   (f temp))</div><div style>
<br></div><div style>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.</div>
<div style><br></div><div style>  -Patrick</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 9, 2013 at 7:50 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">I tried your code with Bigloo, Chicken and Gambit.  All three systems give the same result, so I doubt there is a bug.  Perhaps you can explain what you are trying to achieve.<br>

<br>
Marc<br>
<div><div class="h5"><br>
On Dec 9, 2013, at 10:10 PM, Patrick Li <<a href="mailto:patrickli.2001@gmail.com">patrickli.2001@gmail.com</a>> wrote:<br>
<br>
> Hello!<br>
><br>
> I've been writing some tricky code involving continuations, and ran into the<br>
> following surprising behavior from Gambit v.4.6.2 running on OSX.<br>
><br>
> I have two versions of "make-jp", that I believe should be<br>
> equivalent.<br>
><br>
>    Version 1:<br>
>       (define (make-jp block)<br>
>         (let [(return-point '())]<br>
>           (call/cc (lambda (ret)<br>
>             (define (jp x)<br>
>               (call/cc (lambda (ret)<br>
>                  (let [(r return-point)]<br>
>                    (set! return-point ret)<br>
>                    (r x)))))<br>
>             (set! return-point ret)<br>
>             (let [(result (block jp))]<br>
>               (return-point result))))))<br>
><br>
>    Version 2:<br>
>       (define (make-jp block)<br>
>         (let [(return-point '())]<br>
>           (call/cc (lambda (ret)<br>
>             (define (jp x)<br>
>               (call/cc (lambda (ret)<br>
>                  (let [(r return-point)]<br>
>                    (set! return-point ret)<br>
>                    (r x)))))<br>
>             (set! return-point ret)<br>
>             (return-point (block jp))))))<br>
><br>
> The only difference is the final line:<br>
><br>
>    Version 1:<br>
>       (let [(result (block jp))]<br>
>         (return-point result))<br>
><br>
>    Version 2:<br>
>       (return-point (block jp))<br>
><br>
><br>
> However, I get different behavior when I test with the following code:<br>
><br>
>    Testing Code:<br>
>       (let* [(j '())]<br>
>         (make-jp (lambda (y)<br>
>            (set! j y)<br>
>            (y 0)<br>
>            10))<br>
>         (println "GOT: " (j "X")))<br>
><br>
>    Version 1 prints:<br>
>       GOT: 10<br>
><br>
>    Version 2 prints:<br>
>       GOT: X<br>
><br>
> Out of the two behaviours, I expect the answer given by Version 1.<br>
><br>
> Can anyone verify whether this is a bug, and whether the latest<br>
> version also shows this behavior?  This fell out of a piece of code<br>
> I'm using to simulate coroutines for an interpreter that I am<br>
> programming. Here I've tried to isolate the problem down to as few<br>
> lines as possible.<br>
><br>
> Once I get my environment fixed, I will try it on the latest version<br>
> of Gambit as well and see if the problem is still there.<br>
><br>
>   -Patrick<br>
><br>
</div></div>> _______________________________________________<br>
> Gambit-list mailing list<br>
> <a href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br>
> <a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
<br>
</blockquote></div><br></div>