[plt-scheme] More PLT Scheme as an Alternative to Matlab

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Aug 13 23:50:40 EDT 2009

On Aug 13, Doug Williams wrote:
> >* However, if you're doing a lot of work *inside* Scheme, then
> >  things can become very inefficient.  For example, say that you
> >  want to loop over a floating point array and multiply all of the
> >  values by a given factor.  What will happen in this case is: each
> >  time you read a value, you allocate a Scheme object for the fp
> >  number, multiplying that allocates a new one, then saving it
> >  copies the result back to the array, leaving the two allocated
> >  values to be GCed.  (There are some JIT-level optimizations for
> >  fp numbers, I don't know if it can save one of these allocations
> >  in this case.)
> My plan would be to do the work inside of Scheme - at least for
> now. It would be interesting to see if there are some JIT
> optimizations planned for the future that could help.

In this case going with a Scheme vector will be faster.

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

Posted on the users mailing list.