[GSLL-devel] making copy-to working in clisp+grid: fix to element-type

Mirko Vukovic mirko.vukovic at gmail.com
Fri Jan 4 15:39:53 UTC 2013


The following works in sbcl+grid:

(copy-to (make-array 2 :element-type 'double-float :initial-contents
'(1.0d0 2.0d0)) 'grid:foreign-array)

But it does not work in clisp+grid.

The root cause lies in the function grid/array.lisp/element-type.  It uses
`(array-element-type grid)'.

But this can present a problem.  Quoting hyperspec:

(Because of *array* <26_glo_a.htm#array> *upgrading*, this *type
specifier*<26_glo_t.htm#type_specifier>can in some cases denote a
*supertype* <26_glo_s.htm#supertype> of the *expressed array element
type*<26_glo_e.htm#expressed_array_element_type>of the
*array*.)

In CLISP, array-element-type returns `T' when passed #(1d0 2d0)

It returns T even when passed a simple array:

(array-element-type (make-array 2 :element-type 'double-float
:initial-contents
                      '(1.0d0 2.0d0)
                      :adjustable nil
                      :fill-pointer nil
                      :displaced-to nil) )

The proposed fix is

(defmethod element-type ((grid array))
  (type-of (row-major-aref grid 0))
  #+skip(array-element-type grid))

Now copy-to works in clisp as well.

Mirko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/gsll-devel/attachments/20130104/af82c352/attachment.html>


More information about the gsll-devel mailing list