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 via
\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
} 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*
{REINITIALIZE-INSTANCE
} \VAR{instance
} \Goos{\kwd{:
}\VAR{initarg
}
62 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
64 Change local slots of
\retval{\VAR{instance
}} according to
\VAR{initarg
}s.
67 \IT{(
\FU*
{SLOT-VALUE
} \VAR{instance
} \VAR{slot
})
}
69 of
\VAR{slot
} in
\VAR{instance
}}.
\kwd{SETF
}able.
72 \IT{(
\FU*
{SLOT-MAKUNBOUND
} \VAR{instance
} \VAR{slot
})
}
74 Make
\VAR{slot
} in
\retval{\VAR{instance
}} unbound.
78 \MC*
{WITH-SLOTS
} (
\Goos{\NEV{\VAR{slot
}}\XOR(
\NEV{\VAR{var
}} \NEV{\VAR{slot
}})
})\\
79 \MC*
{WITH-ACCESSORS
} (
\OPn{(
\NEV{\VAR{var
}}\text{ } \NEV{\VAR{accessor
}})
})
}{\
}}
80 \VAR{instance
} \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
83 Return
\retval{values of
\VAR{form
}s
} after evaluating them in a
84 lexical environment with slots of
\VAR{instance
} visible as
85 \kwd{setf
}able
\VAR{slot
}s or
\VAR{var
}s/with
\VAR{accessor
}s of
86 \VAR{instance
} visible as
\kwd{setf
}able
\VAR{var
}s.
89 \IT{(
\GFU*
{CLASS-NAME
} \VAR{class
})
}
91 \retval{Name of
\VAR{class
}}.
\kwd{setf
}able.
94 \IT{(
\FU*
{CLASS-OF
} \VAR{foo
})
}
96 \retval{Class
} \VAR{foo
} is an instance of.
99 \IT{(
\GFU*
{CHANGE-CLASS
} \DES{\VAR{instance
}} \VAR{new-class
}
100 \Goos{\kwd{:
}\VAR{initarg
} \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
102 Change class of
\retval{\VAR{instance
}} to
\VAR{new-class
}.
105 \IT{(
\GFU*
{MAKE-INSTANCES-OBSOLETE
} \VAR{class
})
}
107 Update instances of
\VAR{class
}.
110 \IT{(
\xorGOO{\GFU*
{INITIALIZE-INSTANCE
} (
\VAR{instance
})\\
111 \GFU*
{UPDATE-INSTANCE-FOR-DIFFERENT-CLASS
} \VAR{
112 previous
}\VAR{current
}}{\
}}
113 \Goos{\kwd{:
}\VAR{initarg
}
114 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
116 Its primary method sets slots on behalf of
\GFU{make-instance
}/of
117 \GFU{change-class
} by means of
\GFU{shared-initialize
}.
120 \IT{(
\GFU*
{UPDATE-INSTANCE-FOR-REDEFINED-CLASS
} \VAR{instances
}
121 \VAR{added-slots
} \VAR{discarded-slots
} \VAR{property-list
}
122 \Goos{\kwd{:
}\VAR{initarg
}
123 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
125 Its primary method sets slots on behalf of
126 \GFU{make-instances-obsolete
} by means of
\GFU{shared-initialize
}.
129 \IT{(
\GFU*
{ALLOCATE-INSTANCE
} \VAR{class
} \Goos{\kwd{:
}\VAR{initarg
}
130 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
132 Return uninitialized
\retval{instance
} of
\VAR{class
}.
135 \IT{(
\GFU*
{SHARED-INITIALIZE
} \VAR{instance
} \VAR{slots
}
136 \Goos{\kwd{:
}\VAR{initarg
}
137 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
139 Fill
\VAR{instance
}'s
\VAR{slots
} using
\VAR{initarg
}s and
140 \kwd{:initform
} forms.
143 \IT{(
\GFU*
{SLOT-MISSING
} \VAR{class
} \VAR{object
} \VAR{slot
}
146 \kwd{slot-makunbound
}\\
147 \kwd{slot-value
}}{\
}}
150 Called in case of attempted access to missing
\VAR{slot
}. Its primary
151 method signals
\kwd{error
}.
154 \IT{(
\GFU*
{SLOT-UNBOUND
} \VAR{class
} \VAR{instance
} \VAR{slot
})
}
156 Called by
\FU{slot-value
} in case of unbound
\VAR{slot
}. Its primary
157 method signals
\kwd{unbound-slot
}.
163 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
164 \subsection[Generic~Functns
]{Generic Functions
}
165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
168 \IT{(
\FU*
{NEXT-METHOD-P
})
}
170 \retval{\T} if enclosing method has a next method.
173 \IT{(
\MC*
{DEFGENERIC
}
174 \xorGOO{\VAR{foo
}\\ (
\kwd{setf
} \VAR{ foo
})
}{\
}}
175 (
\OPn{\VAR{required-var
}}
176 \OP{\kwd*
{\&optional
} \xorGOO{\VAR{var
}\\
177 (
\VAR{var
})
}{\
}^
{\!\!*
}}}
178 \OP{\kwd*
{\&rest
} \VAR{var
}}
179 \OP{\kwd*
{\&key
} \orGOO{%
181 (
\VAR{var
}\XOR(
\kwd{:
}\VAR{key
}
182 \VAR{var
}))
}{\
}^
{\!\!*
}} \Op{\kwd*
{\&allow-other-keys
}}})
184 (
\kwd{:argument-precedence-order
}\RP{\VAR{ required-var
}})\\
185 (
\kwd{declare
}\RP{(
\kwd{optimize
}\OPn{\VAR{ arg
}})
})\\
186 (
\kwd{:documentation
} \NEV{\VAR{string
}})\\
187 (
\kwd{:generic-function-class
} \VAR{ class
}\DF{\kwd{standard-generic-function
}})\\
188 (
\kwd{:method-class
} \VAR{ class
}\DF{\kwd{standard-method
}})\\
189 (
\kwd{:method-combination
} \VAR{ c-type
}\DF{\kwd{standard
}} \OPn{\VAR{ c-arg
}})\\
190 \OPn{(
\kwd{:method
} \VAR{ defmethod-args
})
}}{\
}})
}
192 Define
\retval{generic function
} \VAR{foo
}.
\VAR{defmethod-args
} resemble those of
193 \MC{defmethod
}. For
\VAR{c-type
} see section
\ref{section:Method
197 \IT{(
\FU*
{ENSURE-GENERIC-FUNCTION
}
198 \xorGOO{\VAR{foo
}\\ (
\kwd{setf
} \VAR{ foo
})
}{\
}}
200 \kwd{:argument-precedence-order
}\RP{\VAR{ required-var
}}\\
201 \kwd{:declare
}\RP{(
\kwd{optimize
}\OPn{\VAR{ arg
}})
}\\
202 \kwd{:documentation
} \VAR{ string
}\\
203 \kwd{:generic-function-class
} \VAR{ class
}\\
204 \kwd{:method-class
} \VAR{ class
}\\
205 \kwd{:method-combination
} \VAR{ c-type
} \OPn{\VAR{ c-arg
}}\\
206 \kwd{:lambda-list
} \VAR{ lambda-list
}\\
207 \kwd{:environment
} \VAR{ environment
}}{\
}})
}
209 Define or modify
\retval{generic function
} \VAR{foo
}. For
\VAR{c-type
} see
210 section
\ref{section:Method Combination Types
}.
215 (
\kwd{setf
} \VAR{ foo
})
}{\
}}
216 \Op{\xorGOO{\kwd{:before
}\\
219 \OPn{\VAR{qualifier
}}}{\
}}\DF{primary method
}}
221 (
\VAR{spec-var
} \xorGOO{\VAR{class
}\\
222 (
\kwd{eql
} \VAR{ bar
})
}{\
}})
}{\
}^
{\!\!*
}}
223 \OP{\kwd*
{\&optional
} \xorGOO{\VAR{var
}\\
224 (
\VAR{var
} \OP{\VAR{init
}
225 \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}}
226 \Op{\kwd*
{\&rest
} \VAR{var
}}
227 \OP{\kwd*
{\&key
} \xorGOO{\VAR{var
}\\
231 \OP{\VAR{init
}\Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
232 \Op{\kwd*
{\&allow-other-keys
}}}
233 \OP{\kwd*
{\&aux
}\xorGOO{\VAR{var
}\\
234 (
\VAR{var
} \Op{\VAR{init
}})
}{\
}^
{\!\!*
}}})
235 \orGOO{\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\\
239 Define
\retval{new method
} for generic function
240 \VAR{foo
}.
\VAR{spec-var
}s specialize to either being of
\VAR{class
}
241 or being
\kwd{eql
} \VAR{bar
}, respectively. On invocation,
\VAR{var
}s and
242 \VAR{spec-var
}s of the
\retval{new method
}
243 act like parameters of a function with body
244 \OPn{\VAR{form
}}. Applicable
\VAR{qualifier
}s depend on the
245 \kwd{method-combination
} type; see
246 section
\ref{section:Method Combination Types
}.
249 \IT{(
\xorGOO{\GFU*
{ADD-METHOD
}\\
250 \GFU*
{REMOVE-METHOD
}}{\
}} \VAR{generic-function
} \VAR{method
})
}
252 Add, or remove, respectively,
\VAR{method
} to/from
\retval{\VAR{generic-function
}}.
255 \IT{(
\GFU*
{FIND-METHOD
} \VAR{generic-function
} \VAR{qualifiers
}
256 \VAR{specializers
} \Op{\VAR{error
}\DF{\T}})
}
258 Return suitable
\retval{method
}, or signal
\kwd{error
}.
261 \IT{(
\GFU*
{COMPUTE-APPLICABLE-METHODS
} \VAR{generic-function
}
264 \retval{List of methods
} suitable for
\VAR{args
}, most specific first.
267 \IT{(
\FU*
{CALL-NEXT-METHOD
} \OPn{\VAR{arg
}}\DF{current args
})
}
269 From within a method, call next method with
\VAR{arg
}s; return
273 \IT{(
\GFU*
{NO-APPLICABLE-METHOD
} \VAR{generic-function
}
276 Called on invocation of
\VAR{generic-function
} on
\VAR{arg
}s if
277 there is no applicable method.
280 \IT{(
\xorGOO{\FU*
{INVALID-METHOD-ERROR
} \VAR{ method
}\\
281 \FU*
{METHOD-COMBINATION-ERROR
}}{\
}}
282 \VAR{control
} \OPn{\VAR{arg
}})
}
284 Signal
\kwd{error
} on applicable method, or on method combination,
285 with invalid qualifiers. For
\VAR{control
} and
\VAR{arg
}s see
286 \kwd{format
}, p.\
\pageref{section:Format
}.
289 \IT{(
\GFU*
{NO-NEXT-METHOD
} \VAR{generic-function
}
290 \VAR{method
} \OPn{\VAR{arg
}})
}
292 Called on invocation of
\kwd{call-next-method
} if there is no next method.
295 \IT{(
\GFU*
{FUNCTION-KEYWORDS
} \VAR{method
})
}
297 Return list of
\retval{keyword parameters
} of
\VAR{method
} and
298 \retvalii{\T} if other keys are allowed.
301 \IT{(
\GFU*
{METHOD-QUALIFIERS
} \VAR{method
})
}
303 List of qualifiers of
\VAR{method
}.
309 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
310 \subsection[Method Combi- nation Types
]{Method Combination Types
}
311 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
312 \label{section:Method Combination Types
}
317 Evaluate most specific
\kwd{:around
} method supplying the values of
318 the generic function. From within this method,
\FU{call-next-method
}
319 can call less specific
\kwd{:around
} methods if there are any. If
320 not, or if there are no
\kwd{:around
} methods at all, call all
321 \kwd{:before
} methods, most specific first, and the most specific
322 primary method which supplies the values of the calling
323 \FU{call-next-method
} if any, or of the generic function; and which
324 can call less specific primary methods via
325 \FU{call-next-method
}. After its return, call all
\kwd{:after
}
326 methods, least specific first.
332 \kwd*
{LIST
}\XOR \kwd*
{NCONC
}\XOR
338 Simple built-in
\kwd{method-combination
} types; have the same
340 \VAR{c-type
}s defined by the short form of
341 \MC{define-method-combination
}.
344 \IT{(
\MC*
{DEFINE-METHOD-COMBINATION
} \VAR{c-type
} \orGOO{%
345 \kwd{:documentation
} \NEV{\VAR{string
}}\\
346 \kwd{:identity-with-one-argument
} \VAR{ bool
}\DF{\NIL}\\
347 \kwd{:operator
} \VAR{ operator
}\DF{\VAR{c-type
}}}{\
}})
}
349 Short form. Define new
\kwd{method-combination
}
350 \retval{\VAR{c-type
}}. In a generic function using
\VAR{c-type
},
351 evaluate most specific
\kwd{:around
} method supplying the values of
352 the generic function. From within this method,
\FU{call-next-method
}
353 can call less specific
\kwd{:around
} methods if there are any. If
354 not, or if there are no
\kwd{:around
} methods at all,
355 have generic function applied to
\OPn{\VAR{gen-arg
}} return with the
356 values of (
\VAR{c-type
} \Goos{\VAR{primary-method
}
357 \OPn{\VAR{gen-arg
}}}), leftmost
\VAR{primary-method
} being the most
358 specific. In
\MC{defmethod
}, primary methods are denoted by the
359 \VAR{qualifier
} \VAR{c-type
}.
362 \IT{(
\MC*
{DEFINE-METHOD-COMBINATION
} \VAR{c-type
}
363 (
\OPn{\VAR{ord-$
\lambda$
}})
364 (
\OPn{(
\VAR{group
} \xorGOO{%
366 (
\OPn{\VAR{qualifier
}}\text{ } \OP{\kwd{\A}})\\
369 \kwd{:description
} \VAR{ control
}\\
371 \xorGOO{\kwd{:most-specific-first
}\\
372 \kwd{:most-specific-last
}}{\
}}\DF{\kwd{:most-specific-first
}}\\
373 \kwd{:required
} \VAR{ bool
}}{\
}})
})
375 (
\kwd{:arguments
} (
\OPn{\VAR{method-combination-$
\lambda$
}}))\\
376 (
\kwd{:generic-function
} \VAR{ symbol
})\\
377 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\\
381 Long form. Define new method combination type
382 \retval{\VAR{c-type
}}. A call to a generic function using
383 \VAR{c-type
} will be equivalent to a call to the forms returned by
384 \OPn{\VAR{body
}} with
\OPn{\VAR{ord-$
\lambda$
}} bound to
385 \OPn{\VAR{c-arg
}} (cf.\
\MC{DEFGENERIC
}), with
\VAR{symbol
} bound to
386 the generic function, with
\OPn{\VAR{method-combination-$
\lambda$
}}
387 bound to the arguments of the generic function, and with
388 \VAR{group
}s bound to lists of methods. An applicable method becomes
389 a member of the leftmost
\VAR{group
} whose
\VAR{predicate
} or
390 \VAR{qualifier
}s match. Methods can be called via
391 \MC{CALL-METHOD
}. Lambda lists (
\OPn{\VAR{ord-$
\lambda$
}}) and
392 (
\OPn{\VAR{method-combination-$
\lambda$
}}) according to
393 \VAR{ord-$
\lambda$
} on p.\
\pageref{section:Functions
}, the latter
394 enhanced by an optional
\kwd{\&whole
} argument.
397 \IT{(
\MC*
{CALL-METHOD
} \orGOO{\NEV{\VAR{method
}}\\
398 (
\MC*
{MAKE-METHOD
}\text{ } \NEV{\VAR{form
}})
}{\
}}
399 \Op{\NEV{\VAR{next-methods
}}})
}
401 From within an effective method form, call
\VAR{method
} with the
402 arguments of the generic function and
403 with information about its
\VAR{next-methods
}; return
\retval{its