Subject: Re: create specialized vector from general array
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 25 Oct 2008 07:49:21 -0500
Newsgroups: comp.lang.lisp
Message-ID: <74CdnWhAgOlMiJ7UnZ2dnUVZ_sninZ2d@speakeasy.net>
Tamas K Papp  <tkpapp@gmail.com> wrote:
+---------------
| jra wrote:
| > What is the right way to create a new array (1D) from an existing array,
| > where the new array will have the specialized type of the type of the
| > existing array's elements (reguardless of the existing array's type: ie
| > could be t but all elements are double-float, or could be double-float)?
| 
| In case all elements of an array are subtype of some particular type that 
| you want to specialize to, you will have to recognize this yourself and 
| create the new array with an explicit element-type.
| 
| Think about it: what should (vector 1 2 3) specialize to?   Fixnum?  
| (unsigned-byte 2)?  (signed-byte 17)?  You get the idea.
+---------------

While this is true, the OP might want to look at some of the posts
in the latter half of this thread, "Subject: copying arrays":

    http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/e6e10cfa55a74fe5/3cecb0fbdd9f7289

There are a couple of suggested implementations of a COPY-ARRAY
which preserves the original array's properties.

Also see <http://www.cliki.net/SHALLOW-COPY-ARRAY>.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607