+1, except that the "reshape?" argument is not merely boolean, and should be something like "new-domain", defining #f to mean "same as old domain".

On Wed, May 6, 2020 at 3:24 PM Bradley Lucier <xxxxxx@purdue.edu> wrote:
Thank you both for your comments.

Here's what I think I might do:

1.  Change

(define (array->specialized-array array
                                   #!optional
                                   (result-storage-class
generic-storage-class)
                                   (mutable?
(specialized-array-default-mutable?))
                                   (safe?
(specialized-array-default-safe?)))

to

(define (array-copy array
                     #!optional
                     (result-storage-class generic-storage-class)
                     (reshape? #f)
                     (mutable? (specialized-array-default-mutable?))
                     (safe? (specialized-array-default-safe?)))

where the optional reshape? argument can be #f (meaning the new
specialized array result has the same domain as the first argument) or a
new interval that has the same volume as the domain of the first
argument (which will be the domain of the specialized array result).

I think the optional arguments are ordered from most likely to least
likely to be used.

So this copying operation can reshape any array to one of the same volume.

2.  Define

(define (specialized-array-reshape array new-domain)
   ...

that will succeed only if one can guarantee that the new array has an
affine indexer.  If we can't, the error message will suggest making a
new array with array-copy.

I like it.

Comments?

Brad