1 % Copyright (C) 2008, 2009 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-EXISTS-P
} \VAR{foo
} \VAR{bar
})
}
22 \retval{\T} if
\VAR{foo
} has a slot
\VAR{bar
}.
25 \IT{(
\FU*
{SLOT-BOUNDP
} \VAR{instance
} \VAR{slot
})
}
27 \retval{\T} if
\VAR{slot
} in
\VAR{instance
} is bound.
30 \IT{(
\MC*
{DEFCLASS
} \VAR{foo
} (
\OPn{\VAR{superclass
}}\DF{\kwd{standard-object
}})
33 \orGOO{\Goos{\kwd{:reader
} \VAR{reader
}}\\
34 \Goos{\kwd{:writer
} \xorGOO{\VAR{writer
}\\
35 (
{\kwd{setf
}\VAR{ writer
}})
}{\
}}} \\
36 \Goos{\kwd{:accessor
} \VAR{accessor
}} \\
37 \kwd{:allocation
} \xorGOO{\kwd{:instance
}\\
38 \kwd{:class
}}{\
}}\DF{\kwd{:instance
}}\\
39 \Goos{\kwd{:initarg
} \kwd{:
}\VAR{initarg-name
}} \\
40 \kwd{:initform
} \VAR{ form
}\\
41 \kwd{:type
} \VAR{ type
}\\
42 \kwd{:documentation
} \VAR{ slot-doc
}}{\
}})
}{\
}^
{\!\!\!*
}})
43 \orGOO{(
\kwd{:default-initargs
} \Goos{\VAR{name
}\VAR{ value
}})\\
44 (
\kwd{:documentation
} \VAR{ class-doc
})\\
45 (
\kwd{:metaclass
} \VAR{ name
}\DF{\kwd{standard-class
}})
}{\
}})
}
47 Define, as a subclass of
\VAR{superclass
}es,
\retval{class
48 \VAR{foo
}}. In a new instance
\VAR{i
}, a
\VAR{slot
}'s value defaults to
49 \VAR{form
} unless set via
\kwd{:
}\VAR{initarg-name
}; it is readable
50 via (
\VAR{reader
} \VAR{i
}) or (
\VAR{accessor
} \VAR{i
}), and
51 writeable via (
\VAR{writer
} \VAR{i
} \VAR{value
}) or (
\kwd{setf
}
52 (
\VAR{accessor
} \VAR{i
})
\VAR{value
}). With
53 \kwd{:allocation :class
},
\VAR{slot
} is shared by all instances of
57 \IT{(
\FU*
{FIND-CLASS
} \VAR{symbol
} \OP{\VAR{errorp
}\DF{\T}
58 \Op{\VAR{environment
}}})
}
60 Return
\retval{class
} named
\VAR{symbol
}.
\kwd{setf
}able.
63 \IT{(
\GFU*
{MAKE-INSTANCE
} \VAR{class
} \Goos{\kwd{:
}\VAR{initarg
}
64 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
66 Make new
\retval{instance of
\VAR{class
}}.
69 \IT{(
\GFU*
{REINITIALIZE-INSTANCE
} \VAR{instance
} \Goos{\kwd{:
}\VAR{initarg
}
70 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
72 Change local slots of
\retval{\VAR{instance
}} according to
\VAR{initarg
}s.
75 \IT{(
\FU*
{SLOT-VALUE
} \VAR{foo
} \VAR{slot
})
}
77 of
\VAR{slot
} in
\VAR{foo
}}.
\kwd{SETF
}able.
80 \IT{(
\FU*
{SLOT-MAKUNBOUND
} \VAR{instance
} \VAR{slot
})
}
82 Make
\VAR{slot
} in
\retval{\VAR{instance
}} unbound.
86 \MC*
{WITH-SLOTS
} (
\Goos{\NEV{\VAR{slot
}}\XOR(
\NEV{\VAR{var
}} \NEV{\VAR{slot
}})
})\\
87 \MC*
{WITH-ACCESSORS
} (
\OPn{(
\NEV{\VAR{var
}}\text{ } \NEV{\VAR{accessor
}})
})
}{\
}}
88 \VAR{instance
} \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
91 Return
\retval{values of
\VAR{form
}s
} after evaluating them in a
92 lexical environment with slots of
\VAR{instance
} visible as
93 \kwd{setf
}able
\VAR{slot
}s or
\VAR{var
}s/with
\VAR{accessor
}s of
94 \VAR{instance
} visible as
\kwd{setf
}able
\VAR{var
}s.
97 \IT{\arrGOO{(
\GFU*
{CLASS-NAME
} \VAR{class
})\\
98 ((
\kwd{setf
} \GFU*
{CLASS-NAME
})
\VAR{ new-name
} \VAR{class
})
}{.
}}
100 Get/set
\retval{name of
\VAR{class
}}.
103 \IT{(
\FU*
{CLASS-OF
} \VAR{foo
})
}
105 \retval{Class
} \VAR{foo
} is a direct instance of.
108 \IT{(
\GFU*
{CHANGE-CLASS
} \DES{\VAR{instance
}} \VAR{new-class
}
109 \Goos{\kwd{:
}\VAR{initarg
} \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
111 Change class of
\retval{\VAR{instance
}} to
\VAR{new-class
}.
114 \IT{(
\GFU*
{MAKE-INSTANCES-OBSOLETE
} \VAR{class
})
}
116 Update instances of
\VAR{class
}.
119 \IT{(
\xorGOO{\GFU*
{INITIALIZE-INSTANCE
} (
\VAR{instance
})\\
120 \GFU*
{UPDATE-INSTANCE-FOR-DIFFERENT-CLASS
} \VAR{
121 previous
}\VAR{current
}}{\
}}
122 \Goos{\kwd{:
}\VAR{initarg
}
123 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
125 Its primary method sets slots on behalf of
\GFU{make-instance
}/of
126 \GFU{change-class
} by means of
\GFU{shared-initialize
}.
129 \IT{(
\GFU*
{UPDATE-INSTANCE-FOR-REDEFINED-CLASS
} \VAR{instances
}
130 \VAR{added-slots
} \VAR{discarded-slots
} \VAR{property-list
}
131 \Goos{\kwd{:
}\VAR{initarg
}
132 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
134 Its primary method sets slots on behalf of
135 \GFU{make-instances-obsolete
} by means of
\GFU{shared-initialize
}.
138 \IT{(
\GFU*
{ALLOCATE-INSTANCE
} \VAR{class
} \Goos{\kwd{:
}\VAR{initarg
}
139 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
141 Return uninitialized
\retval{instance
} of
\VAR{class
}. Called by
145 \IT{(
\GFU*
{SHARED-INITIALIZE
} \VAR{instance
}
146 \xorGOO{\VAR{slots
}\\
148 \Goos{\kwd{:
}\VAR{initarg
}
149 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
151 Fill
\VAR{instance
}'s
\VAR{slots
} using
\VAR{initarg
}s and
152 \kwd{:initform
} forms.
155 \IT{(
\GFU*
{SLOT-MISSING
} \VAR{class
} \VAR{object
} \VAR{slot
}
158 \kwd{slot-makunbound
}\\
159 \kwd{slot-value
}}{\
}}
162 Called in case of attempted access to missing
\VAR{slot
}. Its primary
163 method signals
\kwd{error
}.
166 \IT{(
\GFU*
{SLOT-UNBOUND
} \VAR{class
} \VAR{instance
} \VAR{slot
})
}
168 Called by
\FU{slot-value
} in case of unbound
\VAR{slot
}. Its primary
169 method signals
\kwd{unbound-slot
}.
175 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176 \subsection[Generic~Functns
]{Generic Functions
}
177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180 \IT{(
\FU*
{NEXT-METHOD-P
})
}
182 \retval{\T} if enclosing method has a next method.
185 \IT{(
\MC*
{DEFGENERIC
}
186 \xorGOO{\VAR{foo
}\\ (
\kwd{setf
} \VAR{ foo
})
}{\
}}
187 (
\OPn{\VAR{required-var
}}
188 \OP{\kwd{\&optional
} \xorGOO{\VAR{var
}\\
189 (
\VAR{var
})
}{\
}^
{\!\!*
}}}
190 \OP{\kwd{\&rest
} \VAR{var
}}
191 \OP{\kwd{\&key
} \xorGOO{%
193 (
\VAR{var
}\XOR(
\kwd{:
}\VAR{key
}
194 \VAR{var
}))
}{\
}^
{\!\!*
}} \Op{\kwd{\&allow-other-keys
}}})
196 (
\kwd{:argument-precedence-order
}\RP{\VAR{ required-var
}})\\
197 (
\kwd{declare
}\RP{(
\kwd{optimize
}\OPn{\VAR{ arg
}})
})\\
198 (
\kwd{:documentation
} \NEV{\VAR{string
}})\\
199 (
\kwd{:generic-function-class
} \VAR{ class
}\DF{\kwd{standard-generic-function
}})\\
200 (
\kwd{:method-class
} \VAR{ class
}\DF{\kwd{standard-method
}})\\
201 (
\kwd{:method-combination
} \VAR{ c-type
}\DF{\kwd{standard
}} \OPn{\VAR{ c-arg
}})\\
202 \OPn{(
\kwd{:method
} \VAR{ defmethod-args
})
}}{\
}})
}
204 Define
\retval{generic function
} \VAR{foo
}.
\VAR{defmethod-args
} resemble those of
205 \MC{defmethod
}. For
\VAR{c-type
} see section
\ref{section:Method
209 \IT{(
\FU*
{ENSURE-GENERIC-FUNCTION
}
210 \xorGOO{\VAR{foo
}\\ (
\kwd{setf
} \VAR{ foo
})
}{\
}}
212 \kwd{:argument-precedence-order
}\RP{\VAR{ required-var
}}\\
213 \kwd{:declare
}\RP{(
\kwd{optimize
}\OPn{\VAR{ arg
}})
}\\
214 \kwd{:documentation
} \VAR{ string
}\\
215 \kwd{:generic-function-class
} \VAR{ class
}\\
216 \kwd{:method-class
} \VAR{ class
}\\
217 \kwd{:method-combination
} \VAR{ c-type
} \OPn{\VAR{ c-arg
}}\\
218 \kwd{:lambda-list
} \VAR{ lambda-list
}\\
219 \kwd{:environment
} \VAR{ environment
}}{\
}})
}
221 Define or modify
\retval{generic function
}
222 \VAR{foo
}.
\kwd{:generic-function-class
} and
\kwd{:lambda-list
} have
223 to be compatible with a pre-existing generic function or with
224 existing methods, respectively. Changes to
\kwd{:method-class
} do
225 not propagate to existing methods. For
\VAR{c-type
} see section
226 \ref{section:Method Combination Types
}.
231 (
\kwd{setf
} \VAR{ foo
})
}{\
}}
232 \Op{\xorGOO{\kwd{:before
}\\
235 \OPn{\VAR{qualifier
}}}{\
}}\DF{primary method
}}
237 (
\VAR{spec-var
} \xorGOO{\VAR{class
}\\
238 (
\kwd{eql
} \VAR{ bar
})
}{\
}})
}{\
}^
{\!\!*
}}
239 \OP{\kwd{\&optional
} \xorGOO{\VAR{var
}\\
240 (
\VAR{var
} \OP{\VAR{init
}
241 \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}}
242 \Op{\kwd{\&rest
} \VAR{var
}}
243 \OP{\kwd{\&key
} \xorGOO{\VAR{var
}\\
247 \OP{\VAR{init
}\Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
248 \Op{\kwd{\&allow-other-keys
}}}
249 \OP{\kwd{\&aux
}\xorGOO{\VAR{var
}\\
250 (
\VAR{var
} \Op{\VAR{init
}})
}{\
}^
{\!\!*
}}})
251 \orGOO{\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\\
255 Define
\retval{new method
} for generic function
256 \VAR{foo
}.
\VAR{spec-var
}s specialize to either being of
\VAR{class
}
257 or being
\kwd{eql
} \VAR{bar
}, respectively. On invocation,
\VAR{var
}s and
258 \VAR{spec-var
}s of the
\retval{new method
}
259 act like parameters of a function with body
260 \OPn{\VAR{form
}}.
\VAR{form
}s are enclosed in an implicit
\SO{block
}
261 \VAR{foo
}. Applicable
\VAR{qualifier
}s depend on the
262 \kwd{method-combination
} type; see
263 section
\ref{section:Method Combination Types
}.
266 \IT{(
\xorGOO{\GFU*
{ADD-METHOD
}\\
267 \GFU*
{REMOVE-METHOD
}}{\
}} \VAR{generic-function
} \VAR{method
})
}
269 Add (if necessary) or remove (if any)
\VAR{method
} to/from
270 \retval{\VAR{generic-function
}}.
273 \IT{(
\GFU*
{FIND-METHOD
} \VAR{generic-function
} \VAR{qualifiers
}
274 \VAR{specializers
} \Op{\VAR{error
}\DF{\T}})
}
276 Return suitable
\retval{method
}, or signal
\kwd{error
}.
279 \IT{(
\GFU*
{COMPUTE-APPLICABLE-METHODS
} \VAR{generic-function
}
282 \retval{List of methods
} suitable for
\VAR{args
}, most specific first.
285 \IT{(
\FU*
{CALL-NEXT-METHOD
} \OPn{\VAR{arg
}}\DF{current args
})
}
287 From within a method, call next method with
\VAR{arg
}s; return
291 \IT{(
\GFU*
{NO-APPLICABLE-METHOD
} \VAR{generic-function
}
294 Called on invocation of
\VAR{generic-function
} on
\VAR{arg
}s if
295 there is no applicable method. Default method signals
\kwd{error
}.
298 \IT{(
\xorGOO{\FU*
{INVALID-METHOD-ERROR
} \VAR{ method
}\\
299 \FU*
{METHOD-COMBINATION-ERROR
}}{\
}}
300 \VAR{control
} \OPn{\VAR{arg
}})
}
302 Signal
\kwd{error
} on applicable method with invalid qualifiers, or
303 on method combination. For
\VAR{control
} and
\VAR{arg
}s see
304 \kwd{format
}, p.\
\pageref{section:Format
}.
307 \IT{(
\GFU*
{NO-NEXT-METHOD
} \VAR{generic-function
}
308 \VAR{method
} \OPn{\VAR{arg
}})
}
310 Called on invocation of
\kwd{call-next-method
} when there is no next
311 method. Default method signals
\kwd{error
}.
314 \IT{(
\GFU*
{FUNCTION-KEYWORDS
} \VAR{method
})
}
316 Return list of
\retval{keyword parameters
} of
\VAR{method
} and
317 \retvalii{\T} if other keys are allowed.
320 \IT{(
\GFU*
{METHOD-QUALIFIERS
} \VAR{method
})
}
322 \retval{List of qualifiers
} of
\VAR{method
}.
328 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
329 \subsection[Method Combi- nation Types
]{Method Combination Types
}
330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
331 \label{section:Method Combination Types
}
336 Evaluate most specific
\kwd{:around
} method supplying the values of
337 the generic function. From within this method,
\FU{call-next-method
}
338 can call less specific
\kwd{:around
} methods if there are any. If
339 not, or if there are no
\kwd{:around
} methods at all, call all
340 \kwd{:before
} methods, most specific first, and the most specific
341 primary method which supplies the values of the calling
342 \FU{call-next-method
} if any, or of the generic function; and which
343 can call less specific primary methods via
344 \FU{call-next-method
}. After its return, call all
\kwd{:after
}
345 methods, least specific first.
351 \kwd*
{LIST
}\XOR \kwd*
{NCONC
}\XOR
357 Simple built-in
\kwd{method-combination
} types; have the same
359 \VAR{c-type
}s defined by the short form of
360 \MC{define-method-combination
}.
363 \IT{(
\MC*
{DEFINE-METHOD-COMBINATION
} \VAR{c-type
} \orGOO{%
364 \kwd{:documentation
} \NEV{\VAR{string
}}\\
365 \kwd{:identity-with-one-argument
} \VAR{ bool
}\DF{\NIL}\\
366 \kwd{:operator
} \VAR{ operator
}\DF{\VAR{c-type
}}}{\
}})
}
368 \EM{Short Form.
} Define new
\kwd{method-combination
}
369 \retval{\VAR{c-type
}}. In a generic function using
\VAR{c-type
},
370 evaluate most specific
\kwd{:around
} method supplying the values of
371 the generic function. From within this method,
\FU{call-next-method
}
372 can call less specific
\kwd{:around
} methods if there are any. If
373 not, or if there are no
\kwd{:around
} methods at all,
374 have generic function applied to
\OPn{\VAR{gen-arg
}} return with the
375 values of (
\VAR{c-type
} \Goos{\VAR{primary-method
}
376 \OPn{\VAR{gen-arg
}}}), leftmost
\VAR{primary-method
} being the most
377 specific. In
\MC{defmethod
}, primary methods are denoted by the
378 \VAR{qualifier
} \VAR{c-type
}.
381 \IT{(
\MC*
{DEFINE-METHOD-COMBINATION
} \VAR{c-type
}
382 (
\OPn{\VAR{ord-$
\lambda$
}})
383 (
\OPn{(
\VAR{group
} \xorGOO{%
385 (
\OPn{\VAR{qualifier
}}\text{ } \OP{\kwd{\A}})\\
388 \kwd{:description
} \VAR{ control
}\\
390 \xorGOO{\kwd{:most-specific-first
}\\
391 \kwd{:most-specific-last
}}{\
}}\DF{\kwd{:most-specific-first
}}\\
392 \kwd{:required
} \VAR{ bool
}}{\
}})
})
394 (
\kwd{:arguments
} \OPn{\VAR{method-combination-$
\lambda$
}})\\
395 (
\kwd{:generic-function
} \VAR{ symbol
})\\
396 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\\
400 \EM{Long Form.
} Define new
\kwd{method-combination
}
401 \retval{\VAR{c-type
}}. A call to a generic function using
402 \VAR{c-type
} will be equivalent to a call to the forms returned by
403 \OPn{\VAR{body
}} with
\OPn{\VAR{ord-$
\lambda$
}} bound to
404 \OPn{\VAR{c-arg
}} (cf.\
\MC{DEFGENERIC
}), with
\VAR{symbol
} bound to
405 the generic function, with
\OPn{\VAR{method-combination-$
\lambda$
}}
406 bound to the arguments of the generic function, and with
407 \VAR{group
}s bound to lists of methods. An applicable method becomes
408 a member of the leftmost
\VAR{group
} whose
\VAR{predicate
} or
409 \VAR{qualifier
}s match. Methods can be called via
410 \MC{CALL-METHOD
}. Lambda lists (
\OPn{\VAR{ord-$
\lambda$
}}) and
411 (
\OPn{\VAR{method-combination-$
\lambda$
}}) according to
412 \VAR{ord-$
\lambda$
} on p.\
\pageref{section:Functions
}, the latter
413 enhanced by an optional
\kwd{\&whole
} argument.
416 \IT{(
\MC*
{CALL-METHOD
} \xorGOO{\NEV{\VAR{method
}}\\
417 (
\MC*
{MAKE-METHOD
}\text{ } \NEV{\VAR{form
}})
}{\
}}%
419 \NEV{\VAR{next-method
}}\\
420 (
\MC*
{MAKE-METHOD
}\text{ } \NEV{\VAR{form
}})
}{\
}^
{\!\!*
}})
})
}
422 From within an effective method form, call
\VAR{method
} with the
423 arguments of the generic function and
424 with information about its
\VAR{next-method
}s; return
\retval{its
434 %%% TeX-master: "clqr"