My fix (as opposed to your fix) to the problem you reported in your
previous email should not exhibit this problem, see my previous email. A
better summary is CLISP is not a preferred platform for anything. There is
a Windows port of SBCL, and has been for quite some time. A better
cross-check on portability would be CCL.
Liam
On Fri, Jan 4, 2013 at 11:47 AM, Mirko Vukovic <mirko.vukovic(a)gmail.com>wrote:
> This is a follow up on my posted fix to copy-to. For some reason this has
> triggered another
> error. I do not understand how that other error is triggered. The error
> and the fix are discussed
> at the bottom of the email
>
> On Fri, Jan 4, 2013 at 10:39 AM, Mirko Vukovic <mirko.vukovic(a)gmail.com>wrote:
>
>> 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* <http://26_glo_a.htm#array> *upgrading*, this *type
>> specifier* <http://26_glo_t.htm#type_specifier> can in some cases denote
>> a *supertype* <http://26_glo_s.htm#supertype> of the *expressed array
>> element type* <http://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
>>
>>
>> After finishing this, I recompiled afresh, and got another error that I
> traced to make-grid-data and make-array
>
> In clisp, make-array will return an array of NIL's even if the
> element-type is specified as double float. In SBCL make-array
> will return an array filled with 1d0.
>
> I had to add some clisp specific code to make-grid-data in order for it to
> initialize properly.
>
> First, a helper function:
> (defun default-element (element-type)
> "Return a default element depending on element-type
> "
> (let ((a-list '((double-float . 1d0)
> (symbol . T))))
> (let ((match (cdr (assoc element-type a-list))))
> (assert match ()
> "Default element type undefined for element-type ~a"
> element-type)
> match)))
>
> And second, a bit of set-up code in make-grid-data. I broke apart the
> (let* statement
> to provide an explicit initial element if it has not been specified
> already:
>
> (defmethod make-grid-data
> ((type (eql 'array)) dimensions rest-spec
> &key (initial-element nil initial-element-p)
> (initial-contents nil initial-contents-p))
> (let ((element-type (top-spec-type rest-spec)))
> #+clisp
> (unless (or initial-element-p
> initial-contents-p)
> (setf initial-element (default-element element-type)
> initial-element-p t))
> (let ((array ... UNCHANGED
>
>
> Summary: To fix to copy-to, I modified (defmethod element-type ((grid
> array))
> For some unknown reason, that triggered an error in the array
> initialization routine.
> To fix that, I had to add code to make-grid-data, so that it fills
> double-float arrays with 0d0
> instead of NIL's
>
> I will continue using this code to see if there are additional problems.
>
> BTW, I realize that CLISP is not a preferred platform for speedy
> computation, but that is what I use
> on Windows, until SBCL gets officially ported to it. And in addition, it
> is a nice cross-check on portability.
>
> Mirko
>
>
>
> _______________________________________________
> GSLL-devel mailing list
> GSLL-devel(a)common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/gsll-devel
>
>
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.
The correct solution when copying from a general array is to explicitly
specify the element-type. This capability is provided by the function #'copy
(copy #(1d0 2d0) :grid-type 'grid:foreign-array :element-type 'double-float)
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.
I have added antik-devel to this email because this an Antik issue and has
nothing to do with GSLL.
On Fri, Jan 4, 2013 at 10:39 AM, Mirko Vukovic <mirko.vukovic(a)gmail.com>wrote:
> 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* <http://26_glo_a.htm#array> *upgrading*, this *type
> specifier* <http://26_glo_t.htm#type_specifier> can in some cases denote
> a *supertype* <http://26_glo_s.htm#supertype> of the *expressed array
> element type* <http://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
>
>
>
> _______________________________________________
> GSLL-devel mailing list
> GSLL-devel(a)common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/gsll-devel
>
>