[Openmcl-devel] Apparent displaced array type bug

David Steuber david at david-steuber.com
Fri Sep 23 02:01:53 PDT 2005


Hi OpenMCL developers,

Please see LispPaste:  http://paste.lisp.org/display/11910

david at interloper:~/usr/src/apress-fractal/src
$ openmcl
Welcome to OpenMCL Version 1.0-test-050914 (DarwinPPC32)!
? (load (compile-file "apress-fractal.lisp"))
Performing compile-time optimization.. please wait.
Done.
#P"/Users/david/usr/src/apress-fractal/src/apress-fractal.dfsl"
? (time (generate-fractals-from-input-file "../sampleinput.txt"))
 > Error in process listener(1): The value #<ARRAY 600x800 type  
(UNSIGNED-BYTE 8), displaced> can not be used to set the value of the  
slot DATA in #<MSET-MAP [-1.0 1.0 1.0 -1.0] 800x600 #x8405A0E>, because  
it is not of type (SIMPLE-ARRAY (MOD 129) (* *)).
 > While executing: CCL::%MAYBE-STD-SETF-SLOT-VALUE-USING-CLASS
 > Type :POP to abort.
Type :? for other options.
1 > :pop

? (quit)


This is code that works in both SBCL 0.9.4.0 and CLisp 2.33.2 on OS X  
10.3.9.  The relevant portion I think is this:

(defclass mset-map ()
   ((left           :type single-float       :initarg :left            
:reader mset-map-left)
    (right          :type single-float       :initarg :right           
:reader mset-map-right)
    (top            :type single-float       :initarg :top             
:reader mset-map-top)
    (bottom         :type single-float       :initarg :bottom          
:reader mset-map-bottom)
    (width          :type (integer 1 4096)   :initarg :width           
:reader mset-map-width)
    (height         :type (integer 1 4096)   :initarg :height          
:reader mset-map-height)
    (x-axis         :type simple-vector)
    (y-axis         :type simple-vector)
    (data           :type (simple-array (integer 0 #.+max-iterations+)  
(* *)))
    (data-alias     :type (simple-array (integer 0 #.+max-iterations+)  
*))))

(defmethod shared-initialize :after ((o mset-map) slot-names &rest  
init-args)
   (declare (ignore slot-names init-args))
   (flet ((make-axis-array (len min max)
            (let ((my-array (make-array len)))
              (loop for i below len
                 with pixelsize = (/ (- max min) len)
                 with start = min
                 do (setf (svref my-array i) (+ start (* i pixelsize))))
              my-array)))
     (with-slots (left right top bottom x-axis y-axis data data-alias  
height width) o
       (setf x-axis (make-axis-array width left right)
             y-axis (nreverse (make-axis-array height bottom top))
             data-alias (make-array (* height width)
                                    :element-type '(integer 0  
#.+max-iterations+)
                                    :initial-element 0)
             data (make-array (list height width)
                                :element-type '(integer 0  
#.+max-iterations+)
                                :displaced-to data-alias)))))

Just in case I am wrong, the complete code is here:

http://www.david-steuber.com/Lisp/Apress-Fractal-Contest/apress- 
fractal.lisp.txt




More information about the Openmcl-devel mailing list