[Openmcl-devel] Apparent displaced array type bug
david at david-steuber.com
Fri Sep 23 07:50:16 EDT 2005
On Sep 23, 2005, at 5:38 AM, Gary Byers wrote:
> The type declaration on the DATA slot asserts that the value of that
> slot should be a (SIMPLE-ARRAY (MOD 129)) of two (unspecified)
> dimensions. In OpenMCL, arrays that're explicitly displaced are not
> SIMPLE-ARRAYs; your code is trying to assign a value to a slot that is
> not of the slot's declared type, and the results of such an attempt
> are undefined.
Xof of #lisp agrees that a displaced array is not a simple array. At
some time in the future, SBCL will also complain about the code I
> OpenMCL tries to signal an error when it can determine that a slot's
> type declaration is being violated by an assignment or an
> initialization. I think that this is useful behavior (either the
> declaration's wrong or the assignment/initialization is), though
> (a) it would be no more or less correct to ignore this
> (b) there are ways of violating type declarations that OpenMCL
> doesn't check for.
> Is the error message below unclear ?
FSVO clear it probably is. I was confused by the popularity contest
pitfall of SBCL and CLisp accepting defective code. I was confused
because I did not know that a displaced array was not a simple array
even though the array it was displaced to is a simple array.
I learned something new today. Sorry for the bogus bug report. And
thanks for the very quick response.
There is on niggling detail left that bothers me. If you refer to the
The paste that jdz made from 0.14.3 complains "not of type
(simple-array (integer 0 128) (* *)). However, the recent cvs version
of openmcl that I am using complains "not of type (simple-array (mod
129) (* *))".
What I had not shown in my code fragment was this bit that occurs prior
to the defclass form:
(eval-when (:compile-toplevel :load-toplevel :execute)
(defconstant +max-iterations+ 128))
So I'm expecting a type (integer 0 128). It doesn't seem obvious to me
that (mod 129) is the same thing. Is it? If not, then there is still
a problem, just a different one than I originally reported.
> On Fri, 23 Sep 2005, David Steuber wrote:
>> 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.
>> ? (time (generate-fractals-from-input-file "../sampleinput.txt"))
>>> Error in process listener(1): The value #<ARRAY 600x800 type
>> 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
>> (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))))
>> (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
>> :initial-element 0)
>> data (make-array (list height width)
>> :element-type '(integer 0
>> :displaced-to data-alias)))))
>> Just in case I am wrong, the complete code is here:
>> Openmcl-devel mailing list
>> Openmcl-devel at clozure.com
More information about the Openmcl-devel