[racket] Style and Performance question

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Mon May 9 23:25:43 EDT 2011

On Mon, May 9, 2011 at 11:19 PM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> Even without typed racket, this:
> (define (my-sqrt y)
>  (let loop [(x (/ y 2.0))]

> is much faster than this:
> (define (my-sqrt y)
>  (let loop [(x (/ y 2))]

Yes, this is one of the optimizations TR does.  :)

As to why TR is so much faster on this program: this is exactly the
sort of program that TR excels at -- generic arithmetic on floats,
which we can turn into fast machine instructions.  You won't find a
better case for TR than this, except if you add complex numbers.
sam th
samth at ccs.neu.edu

Posted on the users mailing list.