1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/04_a.htm

36 lines
8.1 KiB
HTML
Raw Normal View History

2024-04-01 10:24:07 +02:00
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Section 4.1</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="04_.htm">
<LINK REL=UP HREF="04_.htm">
<LINK REL=NEXT HREF="04_b.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="04_.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="04_.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="04_b.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
4.1 Introduction</H2> <P>
A <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> is a (possibly infinite) set of <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>objects</I></A>. An <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> can belong to more than one <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A>. <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>Types</I></A> are never explicitly represented as <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>objects</I></A> by Common Lisp. Instead, they are referred to indirectly by the use of <A REL=DEFINITION HREF="26_glo_t.htm#type_specifier"><I>type specifiers</I></A>, which are <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>objects</I></A> that denote <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>types</I></A>. <P>
New <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>types</I></A> can be defined using <A REL=DEFINITION HREF="m_deftp.htm#deftype"><B>deftype</B></A>, <A REL=DEFINITION HREF="m_defstr.htm#defstruct"><B>defstruct</B></A>, <A REL=DEFINITION HREF="m_defcla.htm#defclass"><B>defclass</B></A>, and <A REL=DEFINITION HREF="m_defi_5.htm#define-condition"><B>define-condition</B></A>. <P>
The <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> <A REL=DEFINITION HREF="f_typep.htm#typep"><B>typep</B></A>, a set membership test, is used to determine whether a given <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> is of a given <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A>. The function <A REL=DEFINITION HREF="f_subtpp.htm#subtypep"><B>subtypep</B></A>, a subset test, is used to determine whether a given <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> is a <A REL=DEFINITION HREF="26_glo_s.htm#subtype"><I>subtype</I></A> of another given <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A>. The function <A REL=DEFINITION HREF="f_tp_of.htm#type-of"><B>type-of</B></A> returns a particular <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> to which a given <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> belongs, even though that <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> must belong to one or more other <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>types</I></A> as well. (For example, every <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> is of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="t_t.htm#t"><B>t</B></A>, but <A REL=DEFINITION HREF="f_tp_of.htm#type-of"><B>type-of</B></A> always returns a <A REL=DEFINITION HREF="26_glo_t.htm#type_specifier"><I>type specifier</I></A> for a <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> more specific than <A REL=DEFINITION HREF="t_t.htm#t"><B>t</B></A>.) <P>
<A REL=DEFINITION HREF="26_glo_o.htm#object"><I>Objects</I></A>, not <A REL=DEFINITION HREF="26_glo_v.htm#variable"><I>variables</I></A>, have <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>types</I></A>. Normally, any <A REL=DEFINITION HREF="26_glo_v.htm#variable"><I>variable</I></A> can have any <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> as its <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A>. It is possible to declare that a <A REL=DEFINITION HREF="26_glo_v.htm#variable"><I>variable</I></A> takes on only values of a given <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> by making an explicit <A REL=DEFINITION HREF="26_glo_t.htm#type_declaration"><I>type declaration</I></A>. <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>Types</I></A> are arranged in a directed acyclic graph, except for the presence of equivalences. <P>
<A REL=DEFINITION HREF="26_glo_d.htm#declaration"><I>Declarations</I></A> can be made about <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>types</I></A> using <A REL=DEFINITION HREF="s_declar.htm#declare"><B>declare</B></A>, <A REL=DEFINITION HREF="f_procla.htm#proclaim"><B>proclaim</B></A>, <A REL=DEFINITION HREF="m_declai.htm#declaim"><B>declaim</B></A>, or <A REL=DEFINITION HREF="s_the.htm#the"><B>the</B></A>. For more information about <A REL=DEFINITION HREF="26_glo_d.htm#declaration"><I>declarations</I></A>, see <A REL=CHILD HREF="03_c.htm">Section 3.3 (Declarations)</A>. <P>
Among the fundamental <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>objects</I></A> of the object system are <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>classes</I></A>. A <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> determines the structure and behavior of a set of other <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>objects</I></A>, which are called its <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instances</I></A>. Every <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> is a <A REL=DEFINITION HREF="26_glo_d.htm#direct_instance"><I>direct instance</I></A> of a <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>. The <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> of an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> determines the set of operations that can be performed on the <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>. For more information, see <A REL=CHILD HREF="04_c.htm">Section 4.3 (Classes)</A>. <P>
It is possible to write <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>functions</I></A> that have behavior <A REL=DEFINITION HREF="26_glo_s.htm#specialized"><I>specialized</I></A> to the class of the <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>objects</I></A> which are their <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>arguments</I></A>. For more information, see <A REL=CHILD HREF="07_f.htm">Section 7.6 (Generic Functions and Methods)</A>. <P>
The <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> of the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> of an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> is called its <A REL=DEFINITION HREF="26_glo_m.htm#metaclass"><I>metaclass</I></A>. For more information about <A REL=DEFINITION HREF="26_glo_m.htm#metaclass"><I>metaclasses</I></A>, see <A REL=CHILD HREF="07_d.htm">Section 7.4 (Meta-Objects)</A>.<HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>