1 % Copyright (C) 2008, 2009, 2010, 2011, 2012, 2014 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; with no Invariant Sections, no Front-Cover Texts and
6 % no Back-Cover Texts. For details see file COPYING.
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19 \IT{(
\FU*
{SLOT-EXISTS-P
} \VAR{foo
} \VAR{bar
})
\qquad\qquad}
21 \retval{\T} if
\VAR{foo
} has a slot
\VAR{bar
}.
24 \IT{(
\FU*
{SLOT-BOUNDP
} \VAR{instance
} \VAR{slot
})
}
26 \retval{\T} if
\VAR{slot
} in
\VAR{instance
} is bound.
29 \IT{(
\MC*
{DEFCLASS
} \VAR{foo
}
30 (
\OPn{\VAR{superclass
}}\DF{\kwd{standard-object
}})
35 \Goos{\kwd{:reader
} \VAR{reader
}}\\
36 \Goos{\kwd{:writer
} \xorGOO{%
38 (
{\kwd{setf
}\VAR{ writer
}})
}{\
}}} \\
39 \Goos{\kwd{:accessor
} \VAR{accessor
}} \\
40 \kwd{:allocation
} \xorGOO{%
42 \kwd{:class
}}{\
}}\DF{\kwd{:instance
}}\\
43 \Goos{\kwd{:initarg
} \kwd{:
}\VAR{initarg-name
}} \\
44 \kwd{:initform
} \VAR{ form
}\\
45 \kwd{:type
} \VAR{ type
}\\
47 \VAR{ slot-doc
}}{\
}})
}{\
}^
{\!\!\!*
}})
49 (
\kwd{:default-initargs
} \Goos{\VAR{name
}\VAR{ value
}})\\
50 (
\kwd{:documentation
} \VAR{ class-doc
})\\
51 (
\kwd{:metaclass
} \VAR{ name
}\DF{\kwd{standard-class
}})
}{\
}})
}
53 Define or modify
\retval{class
\VAR{foo
}} as a subclass of
54 \VAR{superclass
}es. Transform existing instances, if any,
55 by
\GFU{make-instances-obsolete
}. In a new instance
\VAR{i
} of
56 \VAR{foo
}, a
\VAR{slot
}'s value defaults to
\VAR{form
} unless set
57 via
\kwd{:
}\VAR{initarg-name
}; it is readable via (
\VAR{reader
}
58 \VAR{i
}) or (
\VAR{accessor
} \VAR{i
}), and writable via
59 (
\VAR{writer
} \VAR{value
} \VAR{i
}) or (
\kwd{setf
} (
\VAR{accessor
}
60 \VAR{i
})
\VAR{value
}).
\VAR{slot
}s with
\kwd{:allocation :class
}
61 are shared by all instances of class
\VAR{foo
}.
64 \IT{(
\FU*
{FIND-CLASS
} \VAR{symbol
} \OP{\VAR{errorp
}\DF{\T}
65 \Op{\VAR{environment
}}})
}
67 Return
\retval{class
} named
\VAR{symbol
}.
\kwd{setf
}able.
70 \IT{(
\GFU*
{MAKE-INSTANCE
} \VAR{class
} \Goos{\kwd{:
}\VAR{initarg
}
71 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
73 Make new
\retval{instance of
\VAR{class
}}.
76 \IT{(
\GFU*
{REINITIALIZE-INSTANCE
} \VAR{instance
} \Goos{\kwd{:
}\VAR{initarg
}
77 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
79 Change local slots of
\retval{\VAR{instance
}} according to
80 \VAR{initarg
}s by means of
\GFU{shared-initialize
}.
83 \IT{(
\FU*
{SLOT-VALUE
} \VAR{foo
} \VAR{slot
})
}
86 of
\VAR{slot
} in
\VAR{foo
}}.
\kwd{SETF
}able.
89 \IT{(
\FU*
{SLOT-MAKUNBOUND
} \VAR{instance
} \VAR{slot
})
}
91 Make
\VAR{slot
} in
\retval{\VAR{instance
}} unbound.
95 \MC*
{WITH-SLOTS
} (
\Goos{\NEV{\VAR{slot
}}\XOR(
\NEV{\VAR{var
}} \NEV{\VAR{slot
}})
})\\
96 \MC*
{WITH-ACCESSORS
} (
\OPn{(
\NEV{\VAR{var
}}\text{ } \NEV{\VAR{accessor
}})
})
}{\
}}
97 \VAR{instance
} \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
100 Return
\retval{values of
\VAR{form
}s
} after evaluating them in a
101 lexical environment with slots of
\VAR{instance
} visible as
102 \kwd{setf
}able
\VAR{slot
}s or
\VAR{var
}s/with
\VAR{accessor
}s of
103 \VAR{instance
} visible as
\kwd{setf
}able
\VAR{var
}s.
106 \IT{\arrGOO{(
\GFU*
{CLASS-NAME
} \VAR{class
})\\
107 ((
\kwd{setf
} \GFU*
{CLASS-NAME
})
\VAR{ new-name
} \VAR{class
})
}{.
}}
109 Get/set
\retval{name of
\VAR{class
}}.
112 \IT{(
\FU*
{CLASS-OF
} \VAR{foo
})
}
114 \retval{Class
} \VAR{foo
} is a direct instance of.
117 \IT{(
\GFU*
{CHANGE-CLASS
} \DES{\VAR{instance
}} \VAR{new-class
}
118 \Goos{\kwd{:
}\VAR{initarg
} \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
120 Change class of
\retval{\VAR{instance
}} to
\VAR{new-class
}.
121 Retain the status of any slots that are common between
122 \VAR{instance
}'s original class and
\VAR{new-class
}. Initialize
123 any newly added slots with the
\VAR{value
}s of the corresponding
124 \VAR{initarg
}s if any, or with the values of their
125 \kwd{:initform
} forms if not.
128 \IT{(
\GFU*
{MAKE-INSTANCES-OBSOLETE
} \VAR{class
})
}
130 Update all existing instances of
\VAR{class
} using
131 \GFU{update-instance-for-redefined-class
}.
135 \GFU*
{INITIALIZE-INSTANCE
} \VAR{instance
}\\
136 \GFU*
{UPDATE-INSTANCE-FOR-DIFFERENT-CLASS
}
137 \VAR{ previous
}\VAR{current
}}{\
}}
138 \Goos{\kwd{:
}\VAR{initarg
}
139 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
141 Set slots on behalf of
\GFU{make-instance
}/of
142 \GFU{change-class
} by means of
\GFU{shared-initialize
}.
145 \IT{(
\GFU*
{UPDATE-INSTANCE-FOR-REDEFINED-CLASS
}
148 \VAR{discarded-slots
}
149 \VAR{discarded-slots-property-list
}
153 \OPn{\VAR{other-keyarg
}})
}
155 On behalf of
\GFU{make-instances-obsolete
} and by means of
156 \GFU{shared-initialize
}, set any
\VAR{initarg
} slots to their
157 corresponding
\VAR{value
}s; set any remaining
\VAR{added-slots
} to
158 the values of their
\kwd{:initform
} forms. Not to be called by
162 \IT{(
\GFU*
{ALLOCATE-INSTANCE
} \VAR{class
} \Goos{\kwd{:
}\VAR{initarg
}
163 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
165 Return uninitialized
\retval{instance
} of
\VAR{class
}. Called by
169 \IT{(
\GFU*
{SHARED-INITIALIZE
} \VAR{instance
}
171 \VAR{initform-slots
}\\
176 \OPn{\VAR{other-keyarg
}})
}
178 Fill the
\VAR{initarg-slot
}s of
\VAR{instance
} with the
179 corresponding
\VAR{value
}s, and fill those
\VAR{initform-slots
}
180 that are not
\VAR{initarg-slot
}s with the values of their
181 \kwd{:initform
} forms.
185 (
\GFU*
{SLOT-MISSING
} \VAR{class
} \VAR{instance
} \VAR{slot
}
189 \kwd{slot-makunbound
}\\
190 \kwd{slot-value
}}{\
}}
192 (
\GFU*
{SLOT-UNBOUND
} \VAR{class
} \VAR{instance
} \VAR{slot
})
}{.
}}
194 Called on attempted access to non-existing or unbound
195 \VAR{slot
}. Default methods signal
\kwd{error
}/
\kwd{unbound-slot
},
196 respectively. Not to be called by user.
202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203 \subsection[Generic~Functns
]{Generic Functions
}
204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
207 \IT{(
\FU*
{NEXT-METHOD-P
})
}
209 \retval{\T} if enclosing method has a next method.
212 \IT{(
\MC*
{DEFGENERIC
}
213 \xorGOO{\VAR{foo
}\\ (
\kwd{setf
} \VAR{ foo
})
}{\
}}
214 (
\OPn{\VAR{required-var
}}
215 \OP{\kwd{\&optional
} \xorGOO{%
217 (
\VAR{var
})
}{\
}^
{\!\!*
}}}
218 \OP{\kwd{\&rest
} \VAR{var
}}
219 \OP{\kwd{\&key
} \xorGOO{%
221 (
\VAR{var
}\XOR(
\kwd{:
}\VAR{key
}
222 \VAR{var
}))
}{\
}^
{\!\!*
}} \Op{\kwd{\&allow-other-keys
}}})
224 (
\kwd{:argument-precedence-order
}\RP{\VAR{ required-var
}})\\
225 (
\kwd{declare
}\RP{(
\kwd{optimize
}\VAR{ method-selection-optimization
})
})\\
226 (
\kwd{:documentation
} \NEV{\VAR{string
}})\\
227 (
\kwd{:generic-function-class
}
228 \VAR{ gf-class
}\DF{\kwd{standard-generic-function
}})\\
229 (
\kwd{:method-class
} \VAR{ method-class
}\DF{\kwd{standard-method
}})\\
230 (
\kwd{:method-combination
}
231 \VAR{ c-type
}\DF{\kwd{standard
}} \OPn{\VAR{ c-arg
}})\\
232 \OPn{(
\kwd{:method
} \VAR{ defmethod-args
})
}}{\
}})
}
234 Define or modify
\retval{generic function
} \VAR{foo
}. Remove any
235 methods previously defined by defgeneric.
\VAR{gf-class
} and the lambda
236 paramters
\OPn{\VAR{required-var
}} and
\OPn{\VAR{var
}} must be
237 compatible with existing methods.
\VAR{defmethod-args
}
238 resemble those of
\MC{defmethod
}. For
\VAR{c-type
} see section
239 \ref{section:Method Combination Types
}.
242 \IT{(
\FU*
{ENSURE-GENERIC-FUNCTION
}
243 \xorGOO{\VAR{foo
}\\ (
\kwd{setf
} \VAR{ foo
})
}{\
}}
245 \kwd{:argument-precedence-order
}\RP{\VAR{ required-var
}}\\
246 \kwd{:declare
}(
\kwd{optimize
}\VAR{ method-selection-optimization
})\\
247 \kwd{:documentation
} \VAR{ string
}\\
248 \kwd{:generic-function-class
} \VAR{ gf-class
}\\
249 \kwd{:method-class
} \VAR{ method-class
}\\
250 \kwd{:method-combination
} \VAR{ c-type
} \OPn{\VAR{ c-arg
}}\\
251 \kwd{:lambda-list
} \VAR{ lambda-list
}\\
252 \kwd{:environment
} \VAR{ environment
}}{\
}})
}
254 Define or modify
\retval{generic function
}
255 \VAR{foo
}.
\VAR{gf-class
} and
\VAR{lambda-list
}
256 must be compatible with a pre-existing generic function or with
257 existing methods, respectively. Changes to
\VAR{method-class
} do
258 not propagate to existing methods. For
\VAR{c-type
} see section
259 \ref{section:Method Combination Types
}.
264 (
\kwd{setf
} \VAR{ foo
})
}{\
}}
265 \Op{\xorGOO{\kwd{:before
}\\
268 \OPn{\VAR{qualifier
}}}{\
}}\DF{primary method
}}
270 (
\VAR{spec-var
} \xorGOO{\VAR{class
}\\
271 (
\kwd{eql
} \VAR{ bar
})
}{\
}})
}{\
}^
{\!\!*
}}
272 \OP{\kwd{\&optional
} \xorGOO{\VAR{var
}\\
273 (
\VAR{var
} \OP{\VAR{init
}
274 \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}}
275 \Op{\kwd{\&rest
} \VAR{var
}}
276 \OP{\kwd{\&key
} \xorGOO{\VAR{var
}\\
280 \OP{\VAR{init
}\Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
281 \Op{\kwd{\&allow-other-keys
}}}
282 \OP{\kwd{\&aux
}\xorGOO{\VAR{var
}\\
283 (
\VAR{var
} \Op{\VAR{init
}})
}{\
}^
{\!\!*
}}})
284 \orGOO{\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\\
288 Define
\retval{new method
} for generic function
289 \VAR{foo
}.
\VAR{spec-var
}s specialize to either being of
\VAR{class
}
290 or being
\kwd{eql
} \VAR{bar
}, respectively. On invocation,
\VAR{var
}s and
291 \VAR{spec-var
}s of the
\retval{new method
}
292 act like parameters of a function with body
293 \OPn{\VAR{form
}}.
\VAR{form
}s are enclosed in an implicit
\SO{block
}
294 \VAR{foo
}. Applicable
\VAR{qualifier
}s depend on the
295 \kwd{method-combination
} type; see
296 section
\ref{section:Method Combination Types
}.
299 \IT{(
\xorGOO{\GFU*
{ADD-METHOD
}\\
300 \GFU*
{REMOVE-METHOD
}}{\
}} \VAR{generic-function
} \VAR{method
})
}
302 Add (if necessary) or remove (if any)
\VAR{method
} to/from
303 \retval{\VAR{generic-function
}}.
306 \IT{(
\GFU*
{FIND-METHOD
} \VAR{generic-function
} \VAR{qualifiers
}
307 \VAR{specializers
} \Op{\VAR{error
}\DF{\T}})
}
309 Return suitable
\retval{method
}, or signal
\kwd{error
}.
312 \IT{(
\GFU*
{COMPUTE-APPLICABLE-METHODS
} \VAR{generic-function
}
315 \retval{List of methods
} suitable for
\VAR{args
}, most specific first.
318 \IT{(
\FU*
{CALL-NEXT-METHOD
} \OPn{\VAR{arg
}}\DF{current args
})
}
320 From within a method, call next method with
\VAR{arg
}s; return
324 \IT{(
\GFU*
{NO-APPLICABLE-METHOD
} \VAR{generic-function
}
327 Called on invocation of
\VAR{generic-function
} on
\VAR{arg
}s if
328 there is no applicable method. Default method signals
329 \kwd{error
}. Not to be called by user.
333 \FU*
{INVALID-METHOD-ERROR
} \VAR{ method
}\\
334 \FU*
{METHOD-COMBINATION-ERROR
}}{\
}}
335 \VAR{control
} \OPn{\VAR{arg
}})
}
337 Signal
\kwd{error
} on applicable method with invalid qualifiers, or
338 on method combination. For
\VAR{control
} and
\VAR{arg
}s see
339 \kwd{format
}, page
\pageref{section:Format
}.
342 \IT{(
\GFU*
{NO-NEXT-METHOD
} \VAR{generic-function
}
343 \VAR{method
} \OPn{\VAR{arg
}})
}
345 Called on invocation of
\kwd{call-next-method
} when there is no next
346 method. Default method signals
\kwd{error
}. Not to be called by
350 \IT{(
\GFU*
{FUNCTION-KEYWORDS
} \VAR{method
})
}
352 Return list of
\retval{keyword parameters
} of
\VAR{method
} and
353 \retvalii{\T} if other keys are allowed.
356 \IT{(
\GFU*
{METHOD-QUALIFIERS
} \VAR{method
})
}
358 \retval{List of qualifiers
} of
\VAR{method
}.
364 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
365 \subsection[Method Combi- nation Types
]{Method Combination Types
}
366 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
367 \label{section:Method Combination Types
}
372 Evaluate most specific
\kwd{:around
} method supplying the values of
373 the generic function. From within this method,
\FU{call-next-method
}
374 can call less specific
\kwd{:around
} methods if there are any. If
375 not, or if there are no
\kwd{:around
} methods at all, call all
376 \kwd{:before
} methods, most specific first, and the most specific
377 primary method which supplies the values of the calling
378 \FU{call-next-method
} if any, or of the generic function; and which
379 can call less specific primary methods via
380 \FU{call-next-method
}. After its return, call all
\kwd{:after
}
381 methods, least specific first.
387 \kwd*
{LIST
}\XOR \kwd*
{NCONC
}\XOR
393 Simple built-in
\kwd{method-combination
} types; have the same
395 \VAR{c-type
}s defined by the short form of
396 \MC{define-method-combination
}.
399 \IT{(
\MC*
{DEFINE-METHOD-COMBINATION
} \VAR{c-type
}
401 \kwd{:documentation
} \NEV{\VAR{string
}}\\
402 \kwd{:identity-with-one-argument
} \VAR{ bool
}\DF{\NIL}\\
403 \kwd{:operator
} \VAR{ operator
}\DF{\VAR{c-type
}}}{\
}})
}
405 \EM{Short Form.
} Define new
\kwd{method-combination
}
406 \retval{\VAR{c-type
}}. In a generic function using
\VAR{c-type
},
407 evaluate most specific
\kwd{:around
} method supplying the values of
408 the generic function. From within this method,
\FU{call-next-method
}
409 can call less specific
\kwd{:around
} methods if there are any. If
410 not, or if there are no
\kwd{:around
} methods at all,
411 return from the calling
\kwd{call-next-method
} or from the
412 generic function, respectively, the
413 values of (
\VAR{operator
} \OPn{(
\VAR{primary-method
}
414 \OPn{\VAR{gen-arg
}})
}),
\OPn{\VAR{gen-arg
}} being the arguments of the
416 The
\VAR{primary-method
}s are ordered
418 \kwd{:most-specific-first
}\\
419 \kwd{:most-specific-last
}%
420 }{\
}}\DF{\kwd{:most-specific-first
}}}
421 (specified as
\VAR{c-arg
} in
\MC{defgeneric
}).
422 Using
\VAR{c-type
} as the
\VAR{qualifier
} in
\MC{defmethod
}
423 makes the method primary.
426 \IT{(
\MC*
{DEFINE-METHOD-COMBINATION
} \VAR{c-type
}
427 (
\OPn{\VAR{ord-$
\lambda$
}})
428 (
\OPn{(
\VAR{group
} \xorGOO{%
430 (
\OPn{\VAR{qualifier
}}\text{ } \OP{\kwd{\A}})\\
433 \kwd{:description
} \VAR{ control
}\\
435 \xorGOO{\kwd{:most-specific-first
}\\
436 \kwd{:most-specific-last
}}{\
}}\DF{\kwd{:most-specific-first
}}\\
437 \kwd{:required
} \VAR{ bool
}}{\
}})
})
439 (
\kwd{:arguments
} \OPn{\VAR{method-combination-$
\lambda$
}})\\
440 (
\kwd{:generic-function
} \VAR{ symbol
})\\
441 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\\
445 \EM{Long Form.
} Define new
\kwd{method-combination
}
446 \retval{\VAR{c-type
}}. A call to a generic function using
447 \VAR{c-type
} will be equivalent to a call to the forms returned by
448 \OPn{\VAR{body
}} with
\OPn{\VAR{ord-$
\lambda$
}} bound to
449 \OPn{\VAR{c-arg
}} (cf.\
\MC{DEFGENERIC
}), with
\VAR{symbol
} bound to
450 the generic function, with
\OPn{\VAR{method-combination-$
\lambda$
}}
451 bound to the arguments of the generic function, and with
452 \VAR{group
}s bound to lists of methods. An applicable method becomes
453 a member of the leftmost
\VAR{group
} whose
\VAR{predicate
} or
454 \VAR{qualifier
}s match. Methods can be called via
455 \MC{CALL-METHOD
}. Lambda lists (
\OPn{\VAR{ord-$
\lambda$
}}) and
456 (
\OPn{\VAR{method-combination-$
\lambda$
}}) according to
457 \VAR{ord-$
\lambda$
} on page
\pageref{section:Functions
}, the latter
458 enhanced by an optional
\kwd{\&whole
} argument.
461 \IT{(
\MC*
{CALL-METHOD
} \xorGOO{\NEV{\VAR{method
}}\\
462 (
\MC*
{MAKE-METHOD
}\text{ } \NEV{\VAR{form
}})
}{\
}}%
464 \NEV{\VAR{next-method
}}\\
465 (
\MC*
{MAKE-METHOD
}\text{ } \NEV{\VAR{form
}})
}{\
}^
{\!\!*
}})
})
}
467 From within an effective method form, call
\VAR{method
} with the
468 arguments of the generic function and
469 with information about its
\VAR{next-method
}s; return
\retval{its
479 %%% TeX-master: "clqr"