rif wrote on Fri, Feb 14, 2003 at 06:25:53PM -0500: 
> 
> 
> I spoke too soon.
> > (defun square-df (x)
> >   (declare (double-float x))
> >   (prog ((var 0.0d0))
> >      (setq var (* x x))
> >      var))
> 
> is faster because it doesn't work.  It returns NIL instead of the
> square of the number.  I don't understand why, and I'm still left with
> the question of is there any way to make this faster?

Return of double-floats is very costly (the compiler should have
printed a note informing you of the problem, if not you need to switch
on notes).

Try not to let the double-float "escape" to global variables or as
function returns or as direct function parameters.

If needed, use an array or a struct to pass it around functions by
reference.

One of the uglier sides of real existing Lisp systems...

Martin

Reply via email to