[Ecls-list] aref and multidimensional arrays

Mark Cox markcox80 at gmail.com
Mon Aug 2 05:34:08 UTC 2010


Hi,

I am having trouble with AREF and multi dimensional arrays. For example

(defun a ()
  (let ((rv  (make-array '(10 20) :element-type '(unsigned-byte 32)))
	(pos 0))
    (dotimes (y 10)
      (dotimes (x 20)
	(setf (aref rv y x) pos)
	(incf pos)))
    rv))

(compile 'a)
(format t "~&Expecting 199.~%")
(format t "~&Got ~A.~%" (aref (a) (1- 10) (1- 20)))

Produces
> Expecting 199.
> Got 151665505.

where as with 

(dotimes (pos 200)
   (setf (row-major-aref rv pos) pos))

it does what is expected.

The call to COMPILE is important. It works when not calling COMPILE.

ECL version is: 2f1e68128e16f332
BUILT USING: make realclean && ./configure && make
ARCH: A Mac Pro (64bit Xeons) running Snow Leopard

Cheers
Mark




More information about the ecl-devel mailing list