Why is this declaration needed ?

Didier Verna <[email protected]> Fri, 07 Apr 2006 14:28:00 +0200
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>
        Hello,

I'm trying to understand why a certain declaration is needed in ACL, that
aparently CMU-CL doesn't need to optimize. Consider the following compiled
file:

(declaim (optimize (speed 3)
		   (compilation-speed 0)
		   (safety 0)
		   (debug 0)))

(defun add (to from op)
  (declare (:explain :boxing :calls :types))
  (declare (type (simple-array fixnum (* *)) to))
  (declare (type (simple-array fixnum (* *)) from))
  (declare (type fixnum op))
  (let ((size (array-total-size to)))
    (dotimes (i size)
      (setf (row-major-aref to i)
	    (+ (the fixnum (row-major-aref from i)) op)))))

You see that I have to declare the type of the return value of row-major-aref,
otherwise, ACL tells me it cannot inline the call to +_2OP. However, the FROM
array is properly declared.

I see in the compilation log that the calls to row-major-aref can't be inlined
(because the array dimensions are not known ?). Is it related to the need for
this declaration ?


Thanks.


-- 
Didier Verna, [email protected], http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 44 08 01 85
94276 Le Kremlin-BicĂȘtre, France   Fax.+33 (1) 53 14 59 22   [email protected]