1
0
Fork 0
cl-sites/www.cs.cmu.edu/Groups/AI/html/cltl/clm/node48.html

116 lines
5.4 KiB
HTML
Raw Normal View History

2023-10-25 11:23:21 +02:00
<!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.4. Type Specifiers That Combine</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Type Specifiers That Combine">
<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=tex2html2103 HREF="node49.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html2101 HREF="node44.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html2095 HREF="node47.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html2105 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html2106 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html2104 HREF="node49.html"> Type Specifiers That </A>
<B>Up:</B> <A NAME=tex2html2102 HREF="node44.html"> Type Specifiers</A>
<B> Previous:</B> <A NAME=tex2html2096 HREF="node47.html"> Predicating Type Specifiers</A>
<HR> <P>
<H1><A NAME=SECTION00840000000000000000>4.4. Type Specifiers That Combine</A></H1>
<P>
The following type specifier lists define a type in terms of
other types or objects.
<P>
<DL COMPACT><DT><tt>(member <i>object1</i> <i>object2</i> ...)</tt>
<DD>
This denotes the set
containing precisely those objects named. An object is of
this type if and only if it is <tt>eql</tt> to one of the specified objects.
</DL>
<P>
<hr>
<b>Compatibility note:</b> This is roughly equivalent to
the Interlisp DECL package's <tt>memq</tt>.
<hr><P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
<P>
<DL COMPACT><DT><tt>(eql <i>object</i>)</tt>
<DD>
X3J13 voted in June 1988 (CLOS) <A NAME=2168>&#160;</A> to add the <tt>eql</tt> type specifier.
It may be used as a parameter specializer for CLOS methods
(see section <A HREF="node279.html#IntroductiontoMethodsSECTION">28.1.6.2</A>
and <tt>find-method</tt>).
It denotes the set of the one object named; an object is of
this type if and only if it is <tt>eql</tt> to <i>object</i>. While
<tt>(eql <i>object</i>)</tt> denotes the same type as <tt>(member <i>object</i>)</tt>,
only <tt>(eql <i>object</i>)</tt> may be used as a CLOS parameter specializer.
<P>
</DL>
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<DL COMPACT><DT><tt>(not <i>type</i>)</tt>
<DD>
This denotes the set of all those objects that
are <i>not</i> of the specified type.
<P>
<DT><tt>(and <i>type1</i> <i>type2</i> ...)</tt>
<DD>
This denotes the intersection of
the specified types.
</DL><P>
<hr>
<b>Compatibility note:</b> This is roughly equivalent to
the Interlisp DECL package's <tt>allof</tt>.
<hr><P>
<DL COMPACT><dd>
When <tt>typep</tt> processes an <tt>and</tt> type specifier, it always
tests each of the component types in order from left to right
and stops processing as soon as one component of the intersection has
been found to which the object in question does not belong.
In this respect an <tt>and</tt> type specifier is similar to an
executable <tt>and</tt> form. The purpose of this similarity is to allow
a <tt>satisfies</tt> type specifier to depend on filtering by previous
type specifiers. For example, suppose there were a function <tt>primep</tt>
that takes an integer and says whether it is prime. Suppose also that
it is an error to give any object other than an integer to <tt>primep</tt>.
Then the type specifier
<P><pre>
(and integer (satisfies primep))
</pre><P>
is guaranteed never to result in an error because the function <tt>primep</tt>
will not be invoked unless the object in question has already been
determined to be an integer.
<P>
<DT><tt>(or <i>type1</i> <i>type2</i> ...)</tt>
<DD>
This denotes the union of the
specified types. For example, the type <tt>list</tt> by definition is the same as
<tt>(or null cons)</tt>. Also, the value returned by the function
<tt>position</tt> is always of type <tt>(or null (integer 0 *))</tt>
(either <tt>nil</tt> or a non-negative integer).
</dl>
<P>
<hr>
<b>Compatibility note:</b> This is roughly equivalent to
the Interlisp DECL package's <tt>oneof</tt>.
<hr>
<P>
<dl compact><dd>
As for <tt>and</tt>,
when <tt>typep</tt> processes an <tt>or</tt> type specifier, it always
tests each of the component types in order from left to right
and stops processing as soon as one component of the union has
been found to which the object in question belongs.
<P>
</DL>
<P>
<BR> <HR><A NAME=tex2html2103 HREF="node49.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html2101 HREF="node44.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html2095 HREF="node47.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html2105 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html2106 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html2104 HREF="node49.html"> Type Specifiers That </A>
<B>Up:</B> <A NAME=tex2html2102 HREF="node44.html"> Type Specifiers</A>
<B> Previous:</B> <A NAME=tex2html2096 HREF="node47.html"> Predicating Type Specifiers</A>
<HR> <P>
<HR>
<P><ADDRESS>
AI.Repository@cs.cmu.edu
</ADDRESS>
</BODY>