[plt-scheme] Are superfluous expressions optimized away?

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Feb 21 02:32:53 EST 2007

Actually it looks like they do -- I entered these expressions in

  (compile '(lambda () (void) (printf "foo\n")))
  (compile '(lambda () (printf "foo\n")))
  (require mzscheme)
  (compile '(lambda () (void) (printf "foo\n")))
  (compile '(lambda () (printf "foo\n")))

and the last two (after hard-wiring mzscheme primitives) look shorter
*and* they're identical.

On Feb 20, Robby Findler wrote:
> They don't. But don't take my word for it. Do some timing tests.
> Robby
> On 2/20/07, Derick Eddington <derick.eddington at gmail.com> wrote:
> > Are superfluous expressions, like say '() or (void) when not in tail- or
> > binding- or pass-value-position or any other value-is-used position,
> > optimized away (maybe only when compiled to byte-code)?  I'm wondering
> > if conditional compilation macros like (debug expr ...) which expand to
> > '() or (void) would incur zero performance penalty?  If not, the
> > performance cost is probably very negligible?

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.