emacs.d/clones/lisp/www.cs.cmu.edu/Groups/AI/html/cltl/clm/node264.html

72 lines
3.6 KiB
HTML
Raw Normal View History

2022-08-26 19:11:35 +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>28.1.2.1. Defining Classes</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Defining Classes">
<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=tex2html4962 HREF="node265.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html4960 HREF="node263.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html4954 HREF="node263.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html4964 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html4965 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html4963 HREF="node265.html"> Creating Instances of </A>
<B>Up:</B> <A NAME=tex2html4961 HREF="node263.html"> Classes</A>
<B> Previous:</B> <A NAME=tex2html4955 HREF="node263.html"> Classes</A>
<HR> <P>
<H3><A NAME=SECTION003212100000000000000>28.1.2.1. Defining Classes</A></H3>
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
The macro <tt>defclass</tt> is used to define a new named class.
The definition of a class includes the following:
<P>
<UL><LI> The name of the new class. For newly defined classes
this is a proper name.
<P>
<LI> The list of the direct superclasses of the new class.
<P>
<LI> A set of <i>slot specifiers</i>. Each slot specifier
includes the name of the slot and zero or more <i>slot options</i>. A
slot option pertains only to a single slot. If a class definition
contains two slot specifiers with the same name, an error is signaled.
<P>
<LI> A set of <i>class options</i>. Each class option pertains
to the class as a whole.
</UL>
The slot options and class options of the <tt>defclass</tt> form provide
mechanisms for the following:
<P>
<UL><LI> Supplying a default initial value form for a given slot.
<P>
<LI> Requesting that methods for generic functions
be automatically generated for reading or writing slots.
<P>
<LI> Controlling whether a given slot is shared by instances
of the class or whether each instance of the class has its own slot.
<P>
<LI> Supplying a set of initialization arguments and initialization
argument defaults to be used in instance creation.
<P>
<P>
<LI> Indicating that the metaclass is to be other than the default.
<P>
<LI> Indicating the expected type for the value stored in the slot.
<P>
<LI> Indicating the documentation string for the slot.
<P>
</UL>
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<BR> <HR><A NAME=tex2html4962 HREF="node265.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html4960 HREF="node263.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html4954 HREF="node263.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html4964 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html4965 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html4963 HREF="node265.html"> Creating Instances of </A>
<B>Up:</B> <A NAME=tex2html4961 HREF="node263.html"> Classes</A>
<B> Previous:</B> <A NAME=tex2html4955 HREF="node263.html"> Classes</A>
<HR> <P>
<HR>
<P><ADDRESS>
AI.Repository@cs.cmu.edu
</ADDRESS>
</BODY>