[racket] call/comp, eq? and call-with-continuation-prompt

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Mar 11 16:03:15 EDT 2014

I've pushed a repair to the compiler.

Since flonum boxing is a form of allocation, it's possible that the
repair will affect the performance of flonum programs. I haven't
detected any such problems, so far; I expect that the programs where
expression movement and unboxing help are simple enough that the
compiler can detect the absence of continuation operations. Still, keep
an eye out for problems.

At Mon, 10 Mar 2014 20:50:12 -0600, Matthew Flatt wrote:
> I think this is a compiler bug, where the compiler is changing
> 
>    (let ([a (cons 1 2)])
>      (call-with-composable-continuation (λ (k) (set! g k)) p)
>      a)
> 
> to
> 
>    (begin
>      (call-with-composable-continuation (λ (k) (set! g k)) p)
>      (cons 1 2))
> 
> so you get a new pair each time the continuation is called.
> 
> I will need to fix the compiler so that it doesn't move allocation past
> an expression that could capture a continuation.
> 
> At Mon, 10 Mar 2014 21:44:19 -0400, Spencer Florence wrote:
> > For some reason the below program returns false:
> > 
> > #lang racket
> > (define g #f)
> > (define p (make-continuation-prompt-tag))
> > (define (t)
> >   (let ([a (cons 1 2)])
> >     (call-with-composable-continuation (λ (k) (set! g k)) p)
> >     a))
> > (call-with-continuation-prompt t p)
> > (eq? (call-with-continuation-prompt g p)
> >        (call-with-continuation-prompt g p))
> > 
> > This happens with call/cc as well. From my understanding a should be
> > allocated before the continuation is captured, so the two calls to g should
> > return the same cell. If I remove the prompt tag the program returns true.
> > 
> > Anyone have any clue whats going on or how to fix?
> > 
> > --Spencer
> > ____________________
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> 
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users


Posted on the users mailing list.