1 % Copyright (C) 2008 Bert Burgemeister
3 % Permission is granted to copy, distribute and/or modify this
4 % document under the terms of the GNU Free Documentation License,
5 % Version 1.2 or any later version published by the Free Software
6 % Foundation; with no Invariant Sections, no Front-Cover Texts and
7 % no Back-Cover Texts. For details see file COPYING.
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 \IT{(
\FU*
{SLOT-BOUNDP
} \VAR{instance
} \VAR{slot
})
}
22 \retval{\T} if
\VAR{slot
} in
\VAR{instance
} is bound.
25 \IT{(
\MC*
{DEFCLASS
} \VAR{foo
} (
\OPn{\VAR{superclass
}}\DF{\kwd{standard-object
}})
26 (
\OPn{\xorGOO{\VAR{slot
}\\
28 \orGOO{\Goos{\kwd{:reader
} \VAR{reader-function
}}\\
29 \Goos{\kwd{:writer
} \VAR{writer-function
}} \\
30 \Goos{\kwd{:accessor
} \VAR{reader-function
}} \\
31 \kwd{:allocation
} \xorGOO{\kwd{:instance
}\\
32 \kwd{:class
}}{\
}}\DF{\kwd{:instance
}}\\
33 \Goos{\kwd{:initarg
} \kwd{:
}\VAR{initarg-name
}} \\
34 \kwd{:initform
} \VAR{ form
}\\
35 \kwd{:type
} \VAR{ type
}\\
36 \kwd{:documentation
} \VAR{ slot-doc
}}{\
}})
}{\
}}})
37 \orGOO{(
\kwd{:default-initargs
} \Goos{\VAR{name
}\VAR{ value
}})\\
38 (
\kwd{:documentation
} \VAR{ class-doc
})\\
39 (
\kwd{:metaclass
} \VAR{ name
}\DF{\kwd{standard-class
}})
}{\
}})
}
41 Define, as a subclass of
\VAR{superclass
}es,
\retval{class
}
42 \VAR{foo
}. In new instances, a
\VAR{slot
}'s value defaults to
43 \VAR{form
} unless set by
\kwd{:
}\VAR{initarg-name
} and is accessible
44 by
\VAR{reader-function
} and
\VAR{writer-function
}. With
45 \kwd{:allocation :class
},
\VAR{slot
} is shared by all instances of
49 \IT{(
\FU*
{FIND-CLASS
} \VAR{symbol
} \OP{\VAR{errorp
}\DF{\T}
50 \Op{\VAR{environment
}}})
}
52 Return
\retval{class object
} named
\VAR{symbol
}.
\kwd{setf
}able.
55 \IT{(
\GFU*
{MAKE-INSTANCE
} \VAR{class
} \Goos{\kwd{:
}\VAR{initarg
}
56 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
58 Make new
\retval{instance of
\VAR{class
}}.
61 \IT{(
\GFU*
{INITIALIZE-INSTANCE
} (
\VAR{instance
}))
}
63 Its primary method sets slots on behalf of
64 \GFU*
{MAKE-INSTANCE
}. Return
\retval{instance
}.
67 \IT{(
\GFU*
{REINITIALIZE-INSTANCE
} \VAR{instance
} \Goos{\kwd{:
}\VAR{initarg
}
68 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
70 Change local slots of
\retval{\VAR{instance
}} according to
\VAR{initarg
}s.
73 \IT{(
\FU*
{SLOT-VALUE
} \VAR{instance
} \VAR{slot
})
}
75 of
\VAR{slot
} in
\VAR{instance
}}.
\kwd{SETF
}able.
78 \IT{(
\FU*
{SLOT-MAKUNBOUND
} \VAR{instance
} \VAR{slot
})
}
80 Make
\VAR{slot
} in
\retval{\VAR{instance
}} unbound.
84 \MC*
{WITH-SLOTS
} (
\Goos{\NEV{\VAR{slot
}}\XOR(
\NEV{\VAR{var
}} \NEV{\VAR{slot
}})
})\\
85 \MC*
{WITH-ACCESSORS
} (
\OPn{(
\NEV{\VAR{var
}}\text{ } \NEV{\VAR{accessor
}})
})
}{\
}}
86 \VAR{instance
} \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
89 Return
\retval{values of
\VAR{form
}s
} after evaluating them in a
90 lexical environment with slots of
\VAR{instance
} visible as
91 \kwd{setf
}able
\VAR{slot
}s or
\VAR{var
}s/with
\VAR{accessor
}s of
92 \VAR{instance
} visible as
\kwd{setf
}able
\VAR{var
}s.
95 \IT{(
\GFU*
{CLASS-NAME
} \VAR{class
})
}
97 \retval{Name of
\VAR{class
}}.
\kwd{setf
}able.
100 \IT{(
\FU*
{CLASS-OF
} \VAR{foo
})
}
102 \retval{Class
} \VAR{foo
} is an instance of.
105 \IT{(
\GFU*
{CHANGE-CLASS
} \DES{\VAR{instance
}} \VAR{new-class
}
106 \Goos{\kwd{:
}\VAR{initarg
} \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
108 Change class of
\retval{\VAR{instance
}} to
\VAR{new-class
}.
111 \IT{(
\GFU*
{UPDATE-INSTANCE-FOR-DIFFERENT-CLASS
} \VAR{previous
}
112 \VAR{current
} \Goos{\kwd{:
}\VAR{initarg
}
113 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
115 Called by
\GFU{change-class
}.
118 \IT{(
\GFU*
{MAKE-INSTANCES-OBSOLETE
} \VAR{class
})
}
120 Update instances of
\VAR{class
}.
123 \IT{(
\GFU*
{UPDATE-INSTANCE-FOR-REDEFINED-CLASS
} \VAR{instances
}
124 \VAR{added-slots
} \VAR{discarded-slots
} \VAR{property-list
}
125 \Goos{\kwd{:
}\VAR{initarg
}
126 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
128 Called by
\GFU{make-instances-obsolete
}.
131 \IT{(
\GFU*
{SHARED-INITIALIZE
} \VAR{instance
} \VAR{slots
}
132 \Goos{\kwd{:
}\VAR{initarg
}
133 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
135 Fill
\VAR{instance
}'s
\VAR{slots
} using
\VAR{initarg
}s and
136 \kwd{:initform
} forms.
139 \IT{(
\GFU*
{SLOT-MISSING
} \VAR{class
} \VAR{object
} \VAR{slot
}
142 \kwd{slot-makunbound
}}{\
}}
145 Called in case of attempted access to missing
\VAR{slot
}. Default primary
146 method signals
\kwd{error
}.
149 \IT{(
\GFU*
{SLOT-UNBOUND
} \VAR{class
} \VAR{instance
} \VAR{slot
})
}
151 Called by
\FU{slot-value
} in case of unbound
\VAR{slot
}. Default primary
152 method signals
\kwd{unbound-slot
}.
158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159 \subsection[Generic~Functns
]{Generic Functions
}
160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 \IT{(
\FU*
{NEXT-METHOD-P
})
}
165 \retval{\T} if enclosing method has a next method.
168 \IT{(
\MC*
{DEFGENERIC
}
169 \xorGOO{\VAR{foo
}\\ (
\kwd{setf
} \VAR{ foo
})
}{\
}}
170 (
\OPn{\VAR{required-var
}}%
171 \OP{\kwd*
{\&optional
} \xorGOO{\VAR{var
}\\
172 (
\VAR{var
})
}{\
}^
{\!\!*
}}}
173 \OP{\kwd*
{\&rest
} \VAR{var
}}
174 \OP{\kwd*
{\&key
} \orGOO{%
176 (
\VAR{var
}\XOR(
\kwd{:
}\VAR{key
}
177 \VAR{var
}))
}{\
}^
{\!\!*
}} \Op{\kwd*
{\&allow-other-keys
}}})
179 (
\kwd{:argument-precedence-order
}\RP{\VAR{ required-var
}})\\
180 (
\kwd{declare
}\RP{(
\kwd{optimize
}\OPn{\VAR{ arg
}})
})\\
181 (
\kwd{:documentation
} \NEV{\VAR{string
}})\\
182 (
\kwd{:generic-function-class
} \VAR{ class
}\DF{\kwd{standard-generic-function
}})\\
183 (
\kwd{:method-class
} \VAR{ class
}\DF{\kwd{standard-method
}})\\
184 (
\kwd{:method-combination
} \VAR{ c-type
} \OPn{\VAR{ arg
}})\\
185 \OPn{(
\kwd{:method
} \VAR{ defmethod-args
})
}}{\
}})
}
187 Define
\retval{generic function
} \VAR{foo
} with
\VAR{defmethod-args
}
188 describing some methods.
\VAR{defmethod-args
} resemble those of
189 \MC{defmethod
}. For
\VAR{c-type
} see section
\ref{section:Method
193 \IT{(
\FU*
{ENSURE-GENERIC-FUNCTION
}
194 \xorGOO{\VAR{foo
}\\ (
\kwd{setf
} \VAR{ foo
})
}{\
}}
196 \kwd{:argument-precedence-order
}\RP{\VAR{ required-var
}}\\
197 \kwd{:declare
}\RP{(
\kwd{optimize
}\OPn{\VAR{ arg
}})
}\\
198 \kwd{:documentation
} \VAR{ string
}\\
199 \kwd{:generic-function-class
} \VAR{ class
}\\
200 \kwd{:method-class
} \VAR{ class
}\\
201 \kwd{:method-combination
} \VAR{ c-type
} \OPn{\VAR{ arg
}}\\
202 \kwd{:lambda-list
} \VAR{ lambda-list
}\\
203 \kwd{:environment
} \VAR{ environment
}}{\
}})
}
205 Define or modify
\retval{generic function
} \VAR{foo
}. For
\VAR{c-type
} see
206 section
\ref{section:Method Combination Types
}.
210 \xorGOO{\VAR{bar
}\\ (
\kwd{setf
} \VAR{ bar
})
}{\
}}
211 \Op{\xorGOO{\kwd{:before
}\\
215 (
\VAR{spec-var
} \xorGOO{\VAR{class
}\\
216 (
\kwd{eql
} \VAR{ foo
})
}{\
}})
}{\
}^
{\!\!*
}}
217 \OP{\kwd*
{\&optional
} \xorGOO{\VAR{var
}\\
218 (
\VAR{var
} \OP{\VAR{init
}
219 \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}}
220 \Op{\kwd*
{\&rest
} \VAR{var
}}
221 \OP{\kwd*
{\&key
} \xorGOO{\VAR{var
}\\
225 \OP{\VAR{init
}\Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
226 \Op{\kwd*
{\&allow-other-keys
}}}
227 \OP{\kwd*
{\&aux
}\xorGOO{\VAR{var
}\\
228 (
\VAR{var
} \Op{\VAR{init
}})
}{\
}^
{\!\!*
}}})
229 \orGOO{\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\\
233 Define
\retval{new method
} for generic function
234 \VAR{bar
}.
\VAR{spec-var
}s specialize to either being of
\VAR{class
}
235 or being
\kwd{eql
} \VAR{foo
}, respectively. On invocation,
\VAR{var
}s and
236 \VAR{spec-var
}s of the
\retval{new method
}
237 act like parameters of a function with body
\OPn{\VAR{form
}}.
240 \IT{(
\xorGOO{\GFU*
{ADD-METHOD
}\\
241 \GFU*
{REMOVE-METHOD
}}{\
}} \VAR{generic-function
} \VAR{method
})
}
243 Add, or remove, respectively,
\VAR{method
} from
\retval{\VAR{generic-function
}}.
246 \IT{(
\FU*
{CALL-NEXT-METHOD
} \OPn{\VAR{arg
}}\DF{current args
})
}
248 From within a method, call next method with
\VAR{arg
}s; return
252 \IT{(
\MC*
{CALL-METHOD
} \orGOO{\NEV{\VAR{method
}}\\
253 (
\MC*
{MAKE-METHOD
} \VAR{ form
})
}{\
}}
254 \Op{\NEV{\VAR{next-methods
}}})
}
256 From within a method form, call
\VAR{method
} with arguments and
257 with information about its
\VAR{next-methods
}; return
\retval{its
261 \IT{(
\GFU*
{NO-APPLICABLE-METHOD
} \VAR{generic-function
}
264 Called on invocation of
\VAR{generic-function
} if there is no applicable method.
267 \IT{(
\xorGOO{\FU*
{INVALID-METHOD-ERROR
} \VAR{ method
}\\
268 \FU*
{METHOD-COMBINATION-ERROR
}}{\
}}
269 \VAR{control
} \OPn{\VAR{arg
}})
}
271 Signal
\kwd{error
} on applicable method, or on method combination,
272 with invalid qualifiers. For
\VAR{control
} and
\VAR{arg
}s see
273 \kwd{format
}, p.\
\pageref{section:Format
}.
276 \IT{(
\GFU*
{NO-NEXT-METHOD
} \VAR{generic-function
}
277 \VAR{method
} \OPn{\VAR{arg
}})
}
279 Called on invocation of
\kwd{call-next-method
} if there is no next method.
282 \IT{(
\GFU*
{FUNCTION-KEYWORDS
} \VAR{method
})
}
284 Return list of
\retval{keyword parameters
} of
\VAR{method
} and
285 \retvalii{\T} of other keys are allowed.
288 \IT{(
\GFU*
{ALLOCATE-INSTANCE
} \VAR{class
} \Goos{\kwd{:
}\VAR{initarg
}
289 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
291 Return uninitialized
\retval{instance
} of
\VAR{class
}.
294 \IT{(
\GFU*
{METHOD-QUALIFIERS
} \VAR{method
})
}
296 List of qualifiers of
\VAR{method
}.
299 \IT{(
\GFU*
{FIND-METHOD
} \VAR{generic-function
} \VAR{qualifiers
}
300 \VAR{specializers
} \Op{\VAR{error
}\DF{\T}})
}
302 Return suitable
\retval{method
}, or signal
\kwd{error
}.
305 \IT{(
\GFU*
{COMPUTE-APPLICABLE-METHODS
} \VAR{generic-function
}
308 \retval{List of methods
} suitable for
\VAR{args
}, most specific first.
314 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315 \subsection[Method Combi- nation Types
]{Method Combination Types
}
316 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
317 \label{section:Method Combination Types
}
320 \IT{\arrGOO{\kwd*
{AND
}\\
330 Built-in method combination types.
335 Standard method combination type, also used if no method combination
339 \IT{(
\MC*
{DEFINE-METHOD-COMBINATION
} \VAR{c-type
} \orGOO{%
340 \kwd{:documentation
} \NEV{\VAR{string
}}\\
341 \kwd{:identity-with-one-argument
} \VAR{ bool
}\DF{\NIL}\\
342 \kwd{:operator
} \VAR{ operator
}\DF{\VAR{c-type
}}}{\
}})
}
344 Short form. Define new method combination type
345 \retval{\VAR{c-type
}}. A call to a generic function using
346 \VAR{c-type
} will be equivalent to (
\VAR{c-type
}
347 \OPn{\VAR{applicable-method
}} \Op{\kwd{:order
}
348 \xorGOO{\kwd{:most-specific-first
}\\
\kwd{:most-specific-last
}}{\
}}}).
351 \IT{(
\MC*
{DEFINE-METHOD-COMBINATION
} \VAR{c-type
}
352 (
\OPn{\VAR{ord-$
\lambda$
}})
353 (
\GOOs{\VAR{name
} \xorGOO{%
354 \GOOp{\VAR{list
}\XOR\kwd{*
}}\\
357 \kwd{:description
} \VAR{ control
}\\
359 \xorGOO{\kwd{:most-specific-first
}\\
360 \kwd{:most-specific-last
}}{\
}}\DF{\kwd{:most-specific-first
}}\\
361 \kwd{:required
} \VAR{ bool
}}{\
}}})
363 (
\kwd{:arguments
} (
\OPn{\VAR{method-combination-$
\lambda$
}}))\\
364 (
\kwd{:generic-function
} \VAR{ symbol
})\\
365 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\\
369 Long form. Define new method combination type
370 \retval{\VAR{c-type
}}. A call to a generic function using
\VAR{c-type
} will be
371 equivalent to a call to the forms returned by
\VAR{body
}. Lambda
372 lists (
\OPn{\VAR{ord-$
\lambda$
}}) and (
\OPn{\VAR{method-combination-$
\lambda$
}})
373 according to
\VAR{ord-$
\lambda$
} on p.\
\pageref{section:Functions
}, the
374 latter enhanced by an optional
\kwd{\&whole
} argument.