85 lines
4.5 KiB
HTML
85 lines
4.5 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
|
||
|
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
|
||
|
<HEAD>
|
||
|
<TITLE>4.10. Type Upgrading</TITLE>
|
||
|
</HEAD>
|
||
|
<BODY>
|
||
|
<meta name="description" value=" Type Upgrading">
|
||
|
<meta name="keywords" value="clm">
|
||
|
<meta name="resource-type" value="document">
|
||
|
<meta name="distribution" value="global">
|
||
|
<P>
|
||
|
<b>Common Lisp the Language, 2nd Edition</b>
|
||
|
<BR> <HR><A NAME=tex2html2173 HREF="node55.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html2171 HREF="node44.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html2167 HREF="node53.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html2175 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html2176 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
||
|
<B> Next:</B> <A NAME=tex2html2174 HREF="node55.html"> Program Structure</A>
|
||
|
<B>Up:</B> <A NAME=tex2html2172 HREF="node44.html"> Type Specifiers</A>
|
||
|
<B> Previous:</B> <A NAME=tex2html2168 HREF="node53.html"> Determining the Type </A>
|
||
|
<HR> <P>
|
||
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
||
|
<H1><A NAME=SECTION008100000000000000000>4.10. Type Upgrading</A></H1>
|
||
|
<P>
|
||
|
X3J13 voted in January 1989
|
||
|
(ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS) <A NAME=2850> </A>
|
||
|
to add new functions by which a program
|
||
|
can determine, in a given Common Lisp implementation, how that
|
||
|
implementation will <i>upgrade</i> a type when constructing an array
|
||
|
specialized to contain elements of that type,
|
||
|
or a complex number specialized to contain parts of that type.
|
||
|
<P>
|
||
|
<BR><b>[Function]</b><BR>
|
||
|
<tt>upgraded-array-element-type</tt> <tt><i>type</I></tt><P>
|
||
|
A type specifier is returned, indicating the element type
|
||
|
of the most specialized array representation capable of holding
|
||
|
items of the specified argument <i>type</i>.
|
||
|
The result is necessarily a supertype of the given <i>type</i>.
|
||
|
Furthermore, if a type <i>A</i> is a subtype of type <i>B</i>, then
|
||
|
<tt>(upgraded-array-element-type <i>A</i>)</tt> is a subtype of
|
||
|
<tt>(upgraded-array-element-type <i>B</i>)</tt>.
|
||
|
<P>
|
||
|
The manner in which an array element type is upgraded depends
|
||
|
only on the element type as such and not on any other property of
|
||
|
the array such as size, rank, adjustability,
|
||
|
presence or absence of a fill pointer, or displacement.
|
||
|
<P>
|
||
|
<hr>
|
||
|
<b>Rationale:</b> If upgrading were allowed to depend on any of these properties,
|
||
|
all of which can be referred to, directly or indirectly, in the
|
||
|
language of type specifiers, then it would not be possible
|
||
|
to displace an array in a consistent and dependable manner
|
||
|
to another array created with the same <tt>:element-type</tt> argument
|
||
|
but differing in one of these properties.
|
||
|
<hr>
|
||
|
<P>
|
||
|
Note that <tt>upgraded-array-element-type</tt> could be defined as
|
||
|
<P><pre>
|
||
|
(defun upgraded-array-element-type (type)
|
||
|
(array-element-type (make-array 0 :element-type type)))
|
||
|
</pre><P>
|
||
|
but this definition has the disadvantage of allocating an array and
|
||
|
then immediately discarding it. The clever implementor surely can
|
||
|
conjure up a more practical approach.
|
||
|
<P>
|
||
|
<BR><b>[Function]</b><BR>
|
||
|
<tt>upgraded-complex-part-type</tt> <tt><i>type</i></tt><P>
|
||
|
A type specifier is returned, indicating the element type
|
||
|
of the most specialized complex number representation capable of having
|
||
|
parts of the specified argument <i>type</i>.
|
||
|
The result is necessarily a supertype of the given <i>type</i>.
|
||
|
Furthermore, if a type <i>A</i> is a subtype of type <i>B</i>, then
|
||
|
<tt>(upgraded-complex-part-type <i>A</i>)</tt> is a subtype of
|
||
|
<tt>(upgraded-complex-part-type <i>B</i>)</tt>.
|
||
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
||
|
<P>
|
||
|
|
||
|
<P>
|
||
|
<BR> <HR><A NAME=tex2html2173 HREF="node55.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html2171 HREF="node44.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html2167 HREF="node53.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html2175 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html2176 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
||
|
<B> Next:</B> <A NAME=tex2html2174 HREF="node55.html"> Program Structure</A>
|
||
|
<B>Up:</B> <A NAME=tex2html2172 HREF="node44.html"> Type Specifiers</A>
|
||
|
<B> Previous:</B> <A NAME=tex2html2168 HREF="node53.html"> Determining the Type </A>
|
||
|
<HR> <P>
|
||
|
<HR>
|
||
|
<P><ADDRESS>
|
||
|
AI.Repository@cs.cmu.edu
|
||
|
</ADDRESS>
|
||
|
</BODY>
|