116 lines
27 KiB
HTML
116 lines
27 KiB
HTML
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>CLHS: Macro DEFCLASS</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="m_w_slts.htm">
|
|
<LINK REL=UP HREF="c_object.htm">
|
|
<LINK REL=NEXT HREF="m_defgen.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="m_w_slts.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_object.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="m_defgen.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="defclass"><I>Macro</I> <B>DEFCLASS</B></A> <P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>defclass</B> <I><I>class-name</I> ({<I>superclass-name</I>}*) ({<I>slot-specifier</I>}*) [[<I>class-option</I>]]</I><P> => <I>new-class</I><P>
|
|
<P>
|
|
<PRE>
|
|
slot-specifier::= slot-name | (slot-name [[slot-option]])
|
|
slot-name::= <A REL=DEFINITION HREF="26_glo_s.htm#symbol">symbol</A>
|
|
slot-option::= {:reader reader-function-name}* |
|
|
{:writer writer-function-name}* |
|
|
{:accessor reader-function-name}* |
|
|
{:allocation allocation-type} |
|
|
{:initarg initarg-name}* |
|
|
{:initform form} |
|
|
{:type type-specifier} |
|
|
{:documentation <A REL=DEFINITION HREF="26_glo_s.htm#string">string</A>}
|
|
function-name::= {<A REL=DEFINITION HREF="26_glo_s.htm#symbol">symbol</A> | (setf <A REL=DEFINITION HREF="26_glo_s.htm#symbol">symbol</A>)}
|
|
class-option::= (:default-initargs . initarg-list) |
|
|
(:documentation <A REL=DEFINITION HREF="26_glo_s.htm#string">string</A>) |
|
|
(:metaclass class-name)
|
|
</PRE>
|
|
<P> <P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>Class-name</I>---a <A REL=DEFINITION HREF="26_glo_n.htm#non-nil"><I>non-nil</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>. <P>
|
|
<I>Superclass-name</I>--a <A REL=DEFINITION HREF="26_glo_n.htm#non-nil"><I>non-nil</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>. <P>
|
|
<I>Slot-name</I>--a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>. The <I>slot-name</I> argument is a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> that is syntactically valid for use as a variable name. <P>
|
|
<I>Reader-function-name</I>---a <A REL=DEFINITION HREF="26_glo_n.htm#non-nil"><I>non-nil</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>. <TT>:reader</TT> can be supplied more than once for a given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. <P>
|
|
<I>Writer-function-name</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> name. <TT>:writer</TT> can be supplied more than once for a given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. <P>
|
|
<I>Reader-function-name</I>---a <A REL=DEFINITION HREF="26_glo_n.htm#non-nil"><I>non-nil</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>. <TT>:accessor</TT> can be supplied more than once for a given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. <P>
|
|
<I>Allocation-type</I>---(member <TT>:instance</TT> <TT>:class</TT>). <TT>:allocation</TT> can be supplied once at most for a given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. <P>
|
|
<I>Initarg-name</I>---a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>. <TT>:initarg</TT> can be supplied more than once for a given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. <P>
|
|
<I>Form</I>---a <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A>. <TT>:init-form</TT> can be supplied once at most for a given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. <P>
|
|
<I>Type-specifier</I>---a <A REL=DEFINITION HREF="26_glo_t.htm#type_specifier"><I>type specifier</I></A>. <TT>:type</TT> can be supplied once at most for a given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. <P>
|
|
<I>Class-option</I>--- refers to the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> as a whole or to all class <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A>. <P>
|
|
<I>Initarg-list</I>---a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> of alternating initialization argument <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>names</I></A> and default initial value <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>forms</I></A>. <TT>:default-initargs</TT> can be supplied at most once. <P>
|
|
<I>Class-name</I>---a <A REL=DEFINITION HREF="26_glo_n.htm#non-nil"><I>non-nil</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>. <TT>:metaclass</TT> can be supplied once at most. <P>
|
|
<I>new-class</I>---the new <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
The macro <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> defines a new named <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>. It returns the new <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> as its result. <P>
|
|
The syntax of <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> provides options for specifying initialization arguments for <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A>, for specifying default initialization values for <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A>, and for requesting that <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A> on specified <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic functions</I></A> be automatically generated for reading and writing the values of <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A>. No reader or writer functions are defined by default; their generation must be explicitly requested. However, <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A> can always be <I>accessed</I> using <A REL=DEFINITION HREF="f_slt_va.htm#slot-value"><B>slot-value</B></A>. <P>
|
|
Defining a new <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> also causes a <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> of the same name to be defined. The predicate <TT>(typep </TT><I>object</I><TT> </TT><I>class-name</I><TT>)</TT> returns true if the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> of the given <I>object</I> is the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> named by <I>class-name</I> itself or a subclass of the class <I>class-name</I>. A <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> can be used as a <A REL=DEFINITION HREF="26_glo_t.htm#type_specifier"><I>type specifier</I></A>. Thus <TT>(typep </TT><I>object</I><TT> </TT><I>class</I><TT>)</TT> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> of the <I>object</I> is <I>class</I> itself or a subclass of <I>class</I>. <P>
|
|
The <I>class-name</I> argument specifies the <A REL=DEFINITION HREF="26_glo_p.htm#proper_name"><I>proper name</I></A> of the new <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>. If a <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> with the same <A REL=DEFINITION HREF="26_glo_p.htm#proper_name"><I>proper name</I></A> already exists and that <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> is an <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A> of <A REL=DEFINITION HREF="t_std_cl.htm#standard-class"><B>standard-class</B></A>, and if the <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> form for the definition of the new <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> specifies a <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> of <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="t_std_cl.htm#standard-class"><B>standard-class</B></A>, the existing <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> is redefined, and instances of it (and its <A REL=DEFINITION HREF="26_glo_s.htm#subclass"><I>subclasses</I></A>) are updated to the new definition at the time that they are next <I>accessed</I>. For details, see <A REL=CHILD HREF="04_cf.htm">Section 4.3.6 (Redefining Classes)</A>. <P>
|
|
Each <I>superclass-name</I> argument specifies a direct <A REL=DEFINITION HREF="26_glo_s.htm#superclass"><I>superclass</I></A> of the new <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>. If the <A REL=DEFINITION HREF="26_glo_s.htm#superclass"><I>superclass</I></A> list is empty, then the <A REL=DEFINITION HREF="26_glo_s.htm#superclass"><I>superclass</I></A> defaults depending on the <A REL=DEFINITION HREF="26_glo_m.htm#metaclass"><I>metaclass</I></A>, with <A REL=DEFINITION HREF="t_std_ob.htm#standard-object"><B>standard-object</B></A> being the default for <A REL=DEFINITION HREF="t_std_cl.htm#standard-class"><B>standard-class</B></A>. <P>
|
|
The new <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> will inherit <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A> and <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A> from each of its direct <A REL=DEFINITION HREF="26_glo_s.htm#superclass"><I>superclasses</I></A>, from their direct <A REL=DEFINITION HREF="26_glo_s.htm#superclass"><I>superclasses</I></A>, and so on. For a discussion of how <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A> and <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A> are inherited, see <A REL=CHILD HREF="04_cd.htm">Section 4.3.4 (Inheritance)</A>. <P>
|
|
The following slot options are available: <P>
|
|
<P><UL><P>
|
|
<LI> The <TT>:reader</TT> slot option specifies that an <A REL=DEFINITION HREF="26_glo_u.htm#unqualified_method"><I>unqualified method</I></A> is to be defined on the <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> named <I>reader-function-name</I> to read the value of the given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. <P>
|
|
<LI> The <TT>:writer</TT> slot option specifies that an <A REL=DEFINITION HREF="26_glo_u.htm#unqualified_method"><I>unqualified method</I></A> is to be defined on the <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> named <I>writer-function-name</I> to write the value of the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. <P>
|
|
<LI> The <TT>:accessor</TT> slot option specifies that an <A REL=DEFINITION HREF="26_glo_u.htm#unqualified_method"><I>unqualified method</I></A> is to be defined on the generic function named <I>reader-function-name</I> to read the value of the given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> and that an <A REL=DEFINITION HREF="26_glo_u.htm#unqualified_method"><I>unqualified method</I></A> is to be defined on the <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> named <TT>(setf </TT><I>reader-function-name</I><TT>)</TT> to be used with <A REL=DEFINITION HREF="m_setf_.htm#setf"><B>setf</B></A> to modify the value of the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. <P>
|
|
<LI> The <TT>:allocation</TT> slot option is used to specify where storage is to be allocated for the given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. Storage for a <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> can be located in each instance or in the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> itself. The value of the <I>allocation-type</I> argument can be either the keyword <TT>:instance</TT> or the keyword <TT>:class</TT>. If the <TT>:allocation</TT> slot option is not specified, the effect is the same as specifying <TT>:allocation :instance</TT>. <P><UL><LI> If <I>allocation-type</I> is <TT>:instance</TT>, a <A REL=DEFINITION HREF="26_glo_l.htm#local_slot"><I>local slot</I></A> of the name <I>slot-name</I> is allocated in each instance of the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>. <P>
|
|
<LI> If <I>allocation-type</I> is <TT>:class</TT>, a shared <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> of the given name is allocated in the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> created by this <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> form. The value of the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> is shared by all <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instances</I></A> of the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>. If a class C1 defines such a <A REL=DEFINITION HREF="26_glo_s.htm#shared_slot"><I>shared slot</I></A>, any subclass C2 of C1 will share this single <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> unless the <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> form for C2 specifies a <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> of the same <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> or there is a superclass of C2 that precedes C1 in the class precedence list of C2 and that defines a <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> of the same <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A>. <P></UL><LI> The <TT>:initform</TT> slot option is used to provide a default initial value form to be used in the initialization of the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. This <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> is evaluated every time it is used to initialize the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. The lexical environment in which this <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> is evaluated is the lexical environment in which the <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> form was evaluated. Note that the lexical environment refers both to variables and to functions. For <A REL=DEFINITION HREF="26_glo_l.htm#local_slot"><I>local slots</I></A>, the dynamic environment is the dynamic environment in which <A REL=DEFINITION HREF="f_mk_ins.htm#make-instance"><B>make-instance</B></A> is called; for shared <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A>, the dynamic environment is the dynamic environment in which the <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> form was evaluated. See <A REL=CHILD HREF="07_a.htm">Section 7.1 (Object Creation and Initialization)</A>. <P>
|
|
No implementation is permitted to extend the syntax of <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> to allow <TT>(</TT><I>slot-name</I><TT> </TT><I>form</I><TT>)</TT> as an abbreviation for <TT>(</TT><I>slot-name</I><TT> :initform </TT><I>form</I><TT>)</TT>. <P>
|
|
<LI> The <TT>:initarg</TT> slot option declares an initialization argument named <I>initarg-name</I> and specifies that this initialization argument initializes the given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. If the initialization argument has a value in the call to <A REL=DEFINITION HREF="f_init_i.htm#initialize-instance"><B>initialize-instance</B></A>, the value will be stored into the given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>, and the slot's <TT>:initform</TT> slot option, if any, is not evaluated. If none of the initialization arguments specified for a given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> has a value, the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> is initialized according to the <TT>:initform</TT> slot option, if specified. <P>
|
|
<LI> The <TT>:type</TT> slot option specifies that the contents of the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> will always be of the specified data type. It effectively declares the result type of the reader generic function when applied to an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> of this <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>. The consequences of attempting to store in a <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> a value that does not satisfy the type of the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> are undefined. The <TT>:type</TT> slot option is further discussed in <A REL=CHILD HREF="07_ec.htm">Section 7.5.3 (Inheritance of Slots and Slot Options)</A>. <P>
|
|
<LI> The <TT>:documentation</TT> slot option provides a <A REL=DEFINITION HREF="26_glo_d.htm#documentation_string"><I>documentation string</I></A> for the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. <TT>:documentation</TT> can be supplied once at most for a given <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. <P></UL><P>
|
|
Each class option is an option that refers to the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> as a whole. The following class options are available: <P>
|
|
<P><UL><LI> The <TT>:default-initargs</TT> class option is followed by a list of alternating initialization argument <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>names</I></A> and default initial value forms. If any of these initialization arguments does not appear in the initialization argument list supplied to <A REL=DEFINITION HREF="f_mk_ins.htm#make-instance"><B>make-instance</B></A>, the corresponding default initial value form is evaluated, and the initialization argument <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> and the <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A>'s value are added to the end of the initialization argument list before the instance is created; see <A REL=CHILD HREF="07_a.htm">Section 7.1 (Object Creation and Initialization)</A>. The default initial value form is evaluated each time it is used. The lexical environment in which this <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> is evaluated is the lexical environment in which the <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> form was evaluated. The dynamic environment is the dynamic environment in which <A REL=DEFINITION HREF="f_mk_ins.htm#make-instance"><B>make-instance</B></A> was called. If an initialization argument <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> appears more than once in a <TT>:default-initargs</TT> class option, an error is signaled. <P>
|
|
<LI> The <TT>:documentation</TT> class option causes a <A REL=DEFINITION HREF="26_glo_d.htm#documentation_string"><I>documentation string</I></A> to be attached with the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>, and attached with kind <A REL=DEFINITION HREF="a_type.htm#type"><B>type</B></A> to the <I>class-name</I>. <TT>:documentation</TT> can be supplied once at most. <P>
|
|
<LI> The <TT>:metaclass</TT> class option is used to specify that instances of the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> being defined are to have a different metaclass than the default provided by the system (the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="t_std_cl.htm#standard-class"><B>standard-class</B></A>). <P>
|
|
<P></UL><P>
|
|
Note the following rules of <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> for <A REL=DEFINITION HREF="26_glo_s.htm#standard_class"><I>standard classes</I></A>: <P>
|
|
<P><UL><P>
|
|
<LI> It is not required that the <A REL=DEFINITION HREF="26_glo_s.htm#superclass"><I>superclasses</I></A> of a <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> be defined before the <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> form for that <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> is evaluated. <P>
|
|
<LI> All the <A REL=DEFINITION HREF="26_glo_s.htm#superclass"><I>superclasses</I></A> of a <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> must be defined before an <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A> of the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> can be made. <P>
|
|
<LI> A <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> must be defined before it can be used as a parameter specializer in a <A REL=DEFINITION HREF="m_defmet.htm#defmethod"><B>defmethod</B></A> form. <P>
|
|
<P></UL><P>
|
|
The object system can be extended to cover situations where these rules are not obeyed. <P>
|
|
Some slot options are inherited by a <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> from its <A REL=DEFINITION HREF="26_glo_s.htm#superclass"><I>superclasses</I></A>, and some can be shadowed or altered by providing a local slot description. No class options except <TT>:default-initargs</TT> are inherited. For a detailed description of how <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A> and slot options are inherited, see <A REL=CHILD HREF="07_ec.htm">Section 7.5.3 (Inheritance of Slots and Slot Options)</A>. <P>
|
|
The options to <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> can be extended. It is required that all implementations signal an error if they observe a class option or a slot option that is not implemented locally. <P>
|
|
It is valid to specify more than one reader, writer, accessor, or initialization argument for a <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. No other slot option can appear more than once in a single slot description, or an error is signaled. <P>
|
|
If no reader, writer, or accessor is specified for a <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>, the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> can only be <I>accessed</I> by the <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> <A REL=DEFINITION HREF="f_slt_va.htm#slot-value"><B>slot-value</B></A>. <P>
|
|
If a <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A> <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> appears as a <A REL=DEFINITION HREF="26_glo_t.htm#top_level_form"><I>top level form</I></A>, the <A REL=DEFINITION HREF="26_glo_c.htm#compiler"><I>compiler</I></A> must make the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> be recognized as a valid <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> in subsequent declarations (as for <A REL=DEFINITION HREF="m_deftp.htm#deftype"><B>deftype</B></A>) and be recognized as a valid <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> for <A REL=DEFINITION HREF="m_defmet.htm#defmethod"><B>defmethod</B></A> <A REL=DEFINITION HREF="26_glo_p.htm#parameter_specializer"><I>parameter specializers</I></A> and for use as the <TT>:metaclass</TT> option of a subsequent <A REL=DEFINITION HREF="#defclass"><B>defclass</B></A>. The <A REL=DEFINITION HREF="26_glo_c.htm#compiler"><I>compiler</I></A> must make the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> definition available to be returned by <A REL=DEFINITION HREF="f_find_c.htm#find-class"><B>find-class</B></A> when its <I>environment</I> <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A> is a value received as the <A REL=DEFINITION HREF="26_glo_e.htm#environment_parameter"><I>environment parameter</I></A> of a <A REL=DEFINITION HREF="26_glo_m.htm#macro"><I>macro</I></A>. <P>
|
|
<P><B>Examples:</B> None.
|
|
<P>
|
|
<P><B>Affected By:</B> None.
|
|
<P>
|
|
<P><B>Exceptional Situations:</B><P>
|
|
<P>
|
|
If there are any duplicate slot names, an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_progra.htm#program-error"><B>program-error</B></A> is signaled. <P>
|
|
If an initialization argument <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> appears more than once in <TT>:default-initargs</TT> class option, an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_progra.htm#program-error"><B>program-error</B></A> is signaled. <P>
|
|
If any of the following slot options appears more than once in a single slot description, an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_progra.htm#program-error"><B>program-error</B></A> is signaled: <TT>:allocation</TT>, <TT>:initform</TT>, <TT>:type</TT>, <TT>:documentation</TT>. <P>
|
|
It is required that all implementations signal an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_progra.htm#program-error"><B>program-error</B></A> if they observe a class option or a slot option that is not implemented locally. <P>
|
|
<P><B>See Also:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="f_docume.htm#documentation"><B>documentation</B></A>, <A REL=DEFINITION HREF="f_init_i.htm#initialize-instance"><B>initialize-instance</B></A>, <A REL=DEFINITION HREF="f_mk_ins.htm#make-instance"><B>make-instance</B></A>, <A REL=DEFINITION HREF="f_slt_va.htm#slot-value"><B>slot-value</B></A>, <A REL=CHILD HREF="04_c.htm">Section 4.3 (Classes)</A>, <A REL=CHILD HREF="04_cd.htm">Section 4.3.4 (Inheritance)</A>, <A REL=CHILD HREF="04_cf.htm">Section 4.3.6 (Redefining Classes)</A>, <A REL=CHILD HREF="04_ce.htm">Section 4.3.5 (Determining the Class Precedence List)</A>, <A REL=CHILD HREF="07_a.htm">Section 7.1 (Object Creation and Initialization)</A> <P>
|
|
<P><B>Notes:</B> None.
|
|
<P>
|
|
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss059.htm">COMPILE-FILE-HANDLING-OF-TOP-LEVEL-FORMS:CLARIFY</A><LI> <A REL=CHILD HREF="../Issues/iss135.htm">DOCUMENTATION-FUNCTION-BUGS:FIX</A><P></UL><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>
|