<div dir="ltr"><div>Your solution is not a good one, because if a general array is passed to copy-to it will cause an error if all the elements are not the same type as the first one. For example, (copy-to #(1.0d0 1)) will behave incorrectly. By the way, your example with #(1d0 2d0) fails on SBCL as well, and should fail everywhere because #( ) is making a general (T) array. It is unfortunate that CLISP apparently does not have specialized arrays, but the proper solution is to use a different function.<br>

<br></div><div>The correct solution when copying from a general array is to explicitly specify the element-type. This capability is provided by the function #'copy<br>(copy #(1d0 2d0) :grid-type 'grid:foreign-array :element-type 'double-float)<br>

<br>The function #'copy-to is provided merely as a convenient shortcut to using #'copy which works in many situations. The solution to your problem is to use copy with explicit element-type instead of copy-to. After debating whether to eliminate copy-to, I have added another optional argument, element-type, that defaults to *default-element-type*, and this should fix your problem. However, it is meant only as a convenience for interactive code, it should really not be put into files relying on the default value specials which may be changed. So I have also removed its use in GSLL itself. This change is untested and made in 86671c4ef057, which is in the multiple-systems branch and will be merged into master  soon.<br>

</div><div><br></div>I have added antik-devel to this email because this an Antik issue and has nothing to do with GSLL.<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 4, 2013 at 10:39 AM, Mirko Vukovic <span dir="ltr"><<a href="mailto:mirko.vukovic@gmail.com" target="_blank">mirko.vukovic@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The following works in sbcl+grid:<br><br>(copy-to (make-array 2 :element-type 'double-float :initial-contents '(1.0d0 2.0d0)) 'grid:foreign-array)<br>

<br>But it does not work in clisp+grid.<br><br>The root cause lies in the function grid/array.lisp/element-type.  It uses `(array-element-type grid)'. <br>
<br>But this can present a problem.  Quoting hyperspec:<br><br>(Because of <a href="http://26_glo_a.htm#array" rel="DEFINITION" target="_blank"><i>array</i></a> 
<i>upgrading</i>, this <a href="http://26_glo_t.htm#type_specifier" rel="DEFINITION" target="_blank"><i>type specifier</i></a> can in some cases denote a <a href="http://26_glo_s.htm#supertype" rel="DEFINITION" target="_blank"><i>supertype</i></a> of the <a href="http://26_glo_e.htm#expressed_array_element_type" rel="DEFINITION" target="_blank"><i>expressed 
array element type</i></a> of the <i>array</i>.) <br><br>In CLISP, array-element-type returns `T' when passed #(1d0 2d0)<br><br>It returns T even when passed a simple array:<br><br>(array-element-type (make-array 2 :element-type 'double-float :initial-contents<br>


                      '(1.0d0 2.0d0)<br>                      :adjustable nil<br>                      :fill-pointer nil<br>                      :displaced-to nil) )<br><br>The proposed fix is<br><br>(defmethod element-type ((grid array))<br>


  (type-of (row-major-aref grid 0))<br>  #+skip(array-element-type grid))<br><br>Now copy-to works in clisp as well.<span class="HOEnZb"><font color="#888888"><br><br>Mirko<br><br><br>
</font></span><br>_______________________________________________<br>
GSLL-devel mailing list<br>
<a href="mailto:GSLL-devel@common-lisp.net">GSLL-devel@common-lisp.net</a><br>
<a href="http://lists.common-lisp.net/cgi-bin/mailman/listinfo/gsll-devel" target="_blank">http://lists.common-lisp.net/cgi-bin/mailman/listinfo/gsll-devel</a><br>
<br></blockquote></div><br></div></div>