[plt-scheme] dead code elimination/closure optimization?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Sat Apr 7 21:24:48 EDT 2007

(As a meta-point, I suspect that Matthew knows how to do these things,
but that he hasn't found them to be profitable ... also the optimizer
does iterate to a fixed point already, iiuc.)

On 4/7/07, Dimitris Vyzovitis <vyzo at media.mit.edu> wrote:
> >  (comp=? (compile '(letrec ([f (lambda () 10)]) (display 2)))
> >          (compile '(display 2)))
> >  ; => #f
> >  ;  because the optimizer is currently conservative about `letrec'
> Ok, letrec is trickier. With standard expansion to
> (let ((f #<undefined>))
>   (set! f (lambda () 10))
>   ...)
> it may be possible to get rid of it with multiple passes, but it requires
> safe mutation removal of sorts (the computation of the value in the
> assingment has no direct side effects)
This is not a correct expansion of letrec, I believe. There is some
detail in the r5 report that I can't quite recall right now, but that
expansion doesn't have the same behavior wrt call/cc as the spec in r5
does. I'm not sure if this has changed in r6 or not.


Posted on the users mailing list.