Re: Function ARRAY-ELEMENT-TYPE



In article
<96353525-4cf6-4cdf-b02a-09159e43252b@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
danb <sogwaldan@xxxxxxxxx> wrote:

* (array-element-type (MAKE-ARRAY '(2)
:ELEMENT-TYPE 'INTEGER
:INITIAL-CONTENTS '(1 2)))
=> T

Why does this function exist? It doesn't seem to do much.

Which function? array-element-type ?
It returns the type T in your example. That's fine.

Your Lisp has decided that the element type of
the above array is of type T. Means it
does not have a special array type for
arrays with element type INTEGER.

Read about Array Upgrading:
http://www.lisp.org/HyperSpec/Body/sec_15-1-2-1.html

Here is an example where a Lisp does not upgrade an
element type:

? (array-element-type (MAKE-ARRAY '(2)
:ELEMENT-TYPE 'fixnum
:INITIAL-CONTENTS '(1 2)))
FIXNUM

See also these examples:

? (array-element-type (MAKE-ARRAY '(2)
:ELEMENT-TYPE '(unsigned-byte 4)
:INITIAL-CONTENTS '(1 2)))
(UNSIGNED-BYTE 8)

? (array-element-type (MAKE-ARRAY '(2)
:ELEMENT-TYPE '(unsigned-byte 9)
:INITIAL-CONTENTS '(1 2)))
(UNSIGNED-BYTE 16)




--Dan

------------------------------------------------
Dan Bensen
http://www.prairienet.org/~dsb/

cl-match: expressive pattern matching in Lisp
http://common-lisp.net/project/cl-match/

--
http://lispm.dyndns.org/
.