7.4 Floating-point numbers
multiple-value-setq
ormultiple-value-bind
onto the expression supplying the value(s). Therefore, code such as the following fails to be optimized:Below are two examples of code that is successfully optimized:(defun baz (x y) (declare (fixnum x y)) (multiple-value-bind (z w) (round x y) (declare (fixnum z w)) (list (+ z 1) (+ w 1.0))))
(defun bar (x y) (declare (fixnum x y)) (multiple-value-bind (z w) (the (values fixnum fixnum) (round x y)) (list (+ z 1) (+ w 1.0))))In some cases, it may be just as efficient to re-calculate the remainder, for example, as follows:(defun foo (x y) (declare (fixnum x y)) (let ((z (round x y))) (declare (fixnum z)) (+ z 1)))
(defun foobar (x y) (declare (float x y)) (let* ((quo (round x y)) (rem (- x (* y (float quo))))) (declare (fixnum quo) (float rem)) (list (+ quo 1) (+ rem 1.0))))
Generated with Harlequin WebMaker