Hello,

experimenting with some ideas of passing multiple values instead of vectors
(similar to Juho Snellman's ray-tracer mentioned in cll) I have run across
the following problem.  Compiling

(defun test (n)
  (declare (type fixnum n))
  (declare (optimize speed))
  (let ((sum 0.0))
    (declare (type single-float sum))
    (dotimes (i n)
      (incf sum
            (multiple-value-call
                (lambda (x0 y0)
                  (declare (type single-float x0 y0))
                  (* x0 y0))
              (values 0.0) (values 1.0))))))

yields 5 optimization notes which can be removed by wrapping the (m-v-c
...) in a (the single-float ...).  But I am astonished that type
propagation of the compiler does not work here (and I would need it for
more complicated cases).  On the other hand, it works when I pass a single
(values ...) argument:

(defun test (n)
  (declare (type fixnum n))
  (declare (optimize speed))
  (let ((sum 0.0))
    (declare (type single-float sum))
    (dotimes (i n)
      (incf sum
            (multiple-value-call
                (lambda (x0 y0)
                  (declare (type single-float x0 y0))
                  (* x0 y0))
              (values 0.0 1.0))))))

I think SBCL behaves the same.  But I did not test it with precisely this
code.

Thanks for any insight,

Nicolas.


Reply via email to