72 lines
4.5 KiB
HTML
72 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>28.1.2.3. Slots</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<meta name="description" value=" Slots">
|
|
<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=tex2html4986 HREF="node267.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html4984 HREF="node263.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html4978 HREF="node265.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html4988 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html4989 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html4987 HREF="node267.html"> Accessing Slots</A>
|
|
<B>Up:</B> <A NAME=tex2html4985 HREF="node263.html"> Classes</A>
|
|
<B> Previous:</B> <A NAME=tex2html4979 HREF="node265.html"> Creating Instances of </A>
|
|
<HR> <P>
|
|
<H3><A NAME=SECTION003212300000000000000>28.1.2.3. Slots</A></H3>
|
|
<P>
|
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
|
An object that has <tt>standard-class</tt> as its metaclass has zero or
|
|
more named slots. The slots of an object are determined by the class
|
|
of the object. Each slot can hold one value. The name of a slot is a
|
|
symbol that is syntactically valid for use as a variable
|
|
name.
|
|
<P>
|
|
When a slot does not have a value, the slot is said to be <i>unbound</i>. When an unbound slot is read, the generic
|
|
function <tt>slot-unbound</tt> is invoked. The system-supplied primary method
|
|
for <tt>slot-unbound</tt> signals an error.
|
|
<P>
|
|
The default initial value form for a slot is defined by the
|
|
<tt>:initform</tt> slot option. When the <tt>:initform</tt> form is used to
|
|
supply a value, it is evaluated in the lexical environment in which
|
|
the <tt>defclass</tt> form was evaluated. The <tt>:initform</tt> along with
|
|
the lexical environment in which the <tt>defclass</tt> form was evaluated
|
|
is called a <i>captured</i> <tt>:initform</tt>.
|
|
See section <A HREF="node292.html#ObjectCreationandInitializationSECTION">28.1.9</A>.
|
|
<P>
|
|
A <i>local slot</i> is defined to be a slot that is visible to exactly
|
|
one instance, namely the one in which the slot is allocated. A <i>shared slot</i> is defined to be a slot that is visible to more than one
|
|
instance of a given class and its subclasses.
|
|
<P>
|
|
A class is said to <i>define</i> a slot with a given name when
|
|
the <tt>defclass</tt> form for that class contains a slot specifier with
|
|
that name. Defining a local slot does not immediately create a slot;
|
|
it causes a slot to be created each time an instance of the class is
|
|
created. Defining a shared slot immediately creates a slot.
|
|
<P>
|
|
The <tt>:allocation</tt> slot option to <tt>defclass</tt> controls the kind
|
|
of slot that is defined. If the value of the <tt>:allocation</tt> slot
|
|
option is <tt>:instance</tt>, a local slot is created. If the value of
|
|
<tt>:allocation</tt> is <tt>:class</tt>, a shared slot is created.
|
|
<P>
|
|
A slot is said to be <i>accessible</i> in an instance of a class if
|
|
the slot is defined by the class of the instance or is inherited from
|
|
a superclass of that class. At most one slot of a given name can be
|
|
accessible in an instance. A shared slot defined by a class is
|
|
accessible in all instances of that class. A detailed explanation of
|
|
the inheritance of slots is given in
|
|
section <A HREF="node270.html#InheritanceofSlotsandSlotOptionsSECTION">28.1.3.2</A>.
|
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
|
<P>
|
|
<BR> <HR><A NAME=tex2html4986 HREF="node267.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html4984 HREF="node263.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html4978 HREF="node265.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html4988 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html4989 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html4987 HREF="node267.html"> Accessing Slots</A>
|
|
<B>Up:</B> <A NAME=tex2html4985 HREF="node263.html"> Classes</A>
|
|
<B> Previous:</B> <A NAME=tex2html4979 HREF="node265.html"> Creating Instances of </A>
|
|
<HR> <P>
|
|
<HR>
|
|
<P><ADDRESS>
|
|
AI.Repository@cs.cmu.edu
|
|
</ADDRESS>
|
|
</BODY>
|