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-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-function
}}\\
34 \Goos{\kwd{:writer
} \VAR{writer-function
}} \\
35 \Goos{\kwd{:accessor
} \VAR{reader-function
}} \\
36 \kwd{:allocation
} \xorGOO{\kwd{:instance
}\\
37 \kwd{:class
}}{\
}}\DF{\kwd{:instance
}}\\
38 \Goos{\kwd{:initarg
} \kwd{:
}\VAR{initarg-name
}} \\
39 \kwd{:initform
} \VAR{ form
}\\
40 \kwd{:type
} \VAR{ type
}\\
41 \kwd{:documentation
} \VAR{ slot-doc
}}{\
}})
}{\
}^
{\!\!\!*
}})
42 \orGOO{(
\kwd{:default-initargs
} \Goos{\VAR{name
}\VAR{ value
}})\\
43 (
\kwd{:documentation
} \VAR{ class-doc
})\\
44 (
\kwd{:metaclass
} \VAR{ name
}\DF{\kwd{standard-class
}})
}{\
}})
}
46 Define, as a subclass of
\VAR{superclass
}es,
\retval{class
}
47 \VAR{foo
}. In new instances, a
\VAR{slot
}'s value defaults to
48 \VAR{form
} unless set via
\kwd{:
}\VAR{initarg-name
} and is accessible
49 by
\VAR{reader-function
} and
\VAR{writer-function
}. With
50 \kwd{:allocation :class
},
\VAR{slot
} is shared by all instances of
54 \IT{(
\FU*
{FIND-CLASS
} \VAR{symbol
} \OP{\VAR{errorp
}\DF{\T}
55 \Op{\VAR{environment
}}})
}
57 Return
\retval{class
} named
\VAR{symbol
}.
\kwd{setf
}able.
60 \IT{(
\GFU*
{MAKE-INSTANCE
} \VAR{class
} \Goos{\kwd{:
}\VAR{initarg
}
61 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
63 Make new
\retval{instance of
\VAR{class
}}.
66 \IT{(
\GFU*
{REINITIALIZE-INSTANCE
} \VAR{instance
} \Goos{\kwd{:
}\VAR{initarg
}
67 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
69 Change local slots of
\retval{\VAR{instance
}} according to
\VAR{initarg
}s.
72 \IT{(
\FU*
{SLOT-VALUE
} \VAR{foo
} \VAR{slot
})
}
74 of
\VAR{slot
} in
\VAR{foo
}}.
\kwd{SETF
}able.
77 \IT{(
\FU*
{SLOT-MAKUNBOUND
} \VAR{instance
} \VAR{slot
})
}
79 Make
\VAR{slot
} in
\retval{\VAR{instance
}} unbound.
83 \MC*
{WITH-SLOTS
} (
\Goos{\NEV{\VAR{slot
}}\XOR(
\NEV{\VAR{var
}} \NEV{\VAR{slot
}})
})\\
84 \MC*
{WITH-ACCESSORS
} (
\OPn{(
\NEV{\VAR{var
}}\text{ } \NEV{\VAR{accessor
}})
})
}{\
}}
85 \VAR{instance
} \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
88 Return
\retval{values of
\VAR{form
}s
} after evaluating them in a
89 lexical environment with slots of
\VAR{instance
} visible as
90 \kwd{setf
}able
\VAR{slot
}s or
\VAR{var
}s/with
\VAR{accessor
}s of
91 \VAR{instance
} visible as
\kwd{setf
}able
\VAR{var
}s.
94 \IT{\arrGOO{(
\GFU*
{CLASS-NAME
} \VAR{class
})\\
95 ((
\kwd{setf
} \GFU*
{CLASS-NAME
})
\VAR{ new-name
} \VAR{class
})
}{.
}}
97 Get/set
\retval{name of
\VAR{class
}}.
100 \IT{(
\FU*
{CLASS-OF
} \VAR{foo
})
}
102 \retval{Class
} \VAR{foo
} is a direct 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*
{MAKE-INSTANCES-OBSOLETE
} \VAR{class
})
}
113 Update instances of
\VAR{class
}.
116 \IT{(
\xorGOO{\GFU*
{INITIALIZE-INSTANCE
} (
\VAR{instance
})\\
117 \GFU*
{UPDATE-INSTANCE-FOR-DIFFERENT-CLASS
} \VAR{
118 previous
}\VAR{current
}}{\
}}
119 \Goos{\kwd{:
}\VAR{initarg
}
120 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
122 Its primary method sets slots on behalf of
\GFU{make-instance
}/of
123 \GFU{change-class
} by means of
\GFU{shared-initialize
}.
126 \IT{(
\GFU*
{UPDATE-INSTANCE-FOR-REDEFINED-CLASS
} \VAR{instances
}
127 \VAR{added-slots
} \VAR{discarded-slots
} \VAR{property-list
}
128 \Goos{\kwd{:
}\VAR{initarg
}
129 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
131 Its primary method sets slots on behalf of
132 \GFU{make-instances-obsolete
} by means of
\GFU{shared-initialize
}.
135 \IT{(
\GFU*
{ALLOCATE-INSTANCE
} \VAR{class
} \Goos{\kwd{:
}\VAR{initarg
}
136 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
138 Return uninitialized
\retval{instance
} of
\VAR{class
}. Called by
142 \IT{(
\GFU*
{SHARED-INITIALIZE
} \VAR{instance
}
143 \xorGOO{\VAR{slots
}\\
145 \Goos{\kwd{:
}\VAR{initarg
}
146 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
148 Fill
\VAR{instance
}'s
\VAR{slots
} using
\VAR{initarg
}s and
149 \kwd{:initform
} forms.
152 \IT{(
\GFU*
{SLOT-MISSING
} \VAR{class
} \VAR{object
} \VAR{slot
}
155 \kwd{slot-makunbound
}\\
156 \kwd{slot-value
}}{\
}}
159 Called in case of attempted access to missing
\VAR{slot
}. Its primary
160 method signals
\kwd{error
}.
163 \IT{(
\GFU*
{SLOT-UNBOUND
} \VAR{class
} \VAR{instance
} \VAR{slot
})
}
165 Called by
\FU{slot-value
} in case of unbound
\VAR{slot
}. Its primary
166 method signals
\kwd{unbound-slot
}.
172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 \subsection[Generic~Functns
]{Generic Functions
}
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177 \IT{(
\FU*
{NEXT-METHOD-P
})
}
179 \retval{\T} if enclosing method has a next method.
182 \IT{(
\MC*
{DEFGENERIC
}
183 \xorGOO{\VAR{foo
}\\ (
\kwd{setf
} \VAR{ foo
})
}{\
}}
184 (
\OPn{\VAR{required-var
}}
185 \OP{\kwd*
{\&optional
} \xorGOO{\VAR{var
}\\
186 (
\VAR{var
})
}{\
}^
{\!\!*
}}}
187 \OP{\kwd*
{\&rest
} \VAR{var
}}
188 \OP{\kwd*
{\&key
} \xorGOO{%
190 (
\VAR{var
}\XOR(
\kwd{:
}\VAR{key
}
191 \VAR{var
}))
}{\
}^
{\!\!*
}} \Op{\kwd*
{\&allow-other-keys
}}})
193 (
\kwd{:argument-precedence-order
}\RP{\VAR{ required-var
}})\\
194 (
\kwd{declare
}\RP{(
\kwd{optimize
}\OPn{\VAR{ arg
}})
})\\
195 (
\kwd{:documentation
} \NEV{\VAR{string
}})\\
196 (
\kwd{:generic-function-class
} \VAR{ class
}\DF{\kwd{standard-generic-function
}})\\
197 (
\kwd{:method-class
} \VAR{ class
}\DF{\kwd{standard-method
}})\\
198 (
\kwd{:method-combination
} \VAR{ c-type
}\DF{\kwd{standard
}} \OPn{\VAR{ c-arg
}})\\
199 \OPn{(
\kwd{:method
} \VAR{ defmethod-args
})
}}{\
}})
}
201 Define
\retval{generic function
} \VAR{foo
}.
\VAR{defmethod-args
} resemble those of
202 \MC{defmethod
}. For
\VAR{c-type
} see section
\ref{section:Method
206 \IT{(
\FU*
{ENSURE-GENERIC-FUNCTION
}
207 \xorGOO{\VAR{foo
}\\ (
\kwd{setf
} \VAR{ foo
})
}{\
}}
209 \kwd{:argument-precedence-order
}\RP{\VAR{ required-var
}}\\
210 \kwd{:declare
}\RP{(
\kwd{optimize
}\OPn{\VAR{ arg
}})
}\\
211 \kwd{:documentation
} \VAR{ string
}\\
212 \kwd{:generic-function-class
} \VAR{ class
}\\
213 \kwd{:method-class
} \VAR{ class
}\\
214 \kwd{:method-combination
} \VAR{ c-type
} \OPn{\VAR{ c-arg
}}\\
215 \kwd{:lambda-list
} \VAR{ lambda-list
}\\
216 \kwd{:environment
} \VAR{ environment
}}{\
}})
}
218 Define or modify
\retval{generic function
}
219 \VAR{foo
}.
\kwd{:generic-function-class
} and
\kwd{:lambda-list
} have
220 to be compatible with a pre-existing generic function or with
221 existing methods, respectively. Changes to
\kwd{:method-class
} do
222 not propagate to existing methods. For
\VAR{c-type
} see section
223 \ref{section:Method Combination Types
}.
228 (
\kwd{setf
} \VAR{ foo
})
}{\
}}
229 \Op{\xorGOO{\kwd{:before
}\\
232 \OPn{\VAR{qualifier
}}}{\
}}\DF{primary method
}}
234 (
\VAR{spec-var
} \xorGOO{\VAR{class
}\\
235 (
\kwd{eql
} \VAR{ bar
})
}{\
}})
}{\
}^
{\!\!*
}}
236 \OP{\kwd*
{\&optional
} \xorGOO{\VAR{var
}\\
237 (
\VAR{var
} \OP{\VAR{init
}
238 \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}}
239 \Op{\kwd*
{\&rest
} \VAR{var
}}
240 \OP{\kwd*
{\&key
} \xorGOO{\VAR{var
}\\
244 \OP{\VAR{init
}\Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
245 \Op{\kwd*
{\&allow-other-keys
}}}
246 \OP{\kwd*
{\&aux
}\xorGOO{\VAR{var
}\\
247 (
\VAR{var
} \Op{\VAR{init
}})
}{\
}^
{\!\!*
}}})
248 \orGOO{\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\\
252 Define
\retval{new method
} for generic function
253 \VAR{foo
}.
\VAR{spec-var
}s specialize to either being of
\VAR{class
}
254 or being
\kwd{eql
} \VAR{bar
}, respectively. On invocation,
\VAR{var
}s and
255 \VAR{spec-var
}s of the
\retval{new method
}
256 act like parameters of a function with body
257 \OPn{\VAR{form
}}.
\VAR{form
}s are enclosed in an implicit
\SO{block
}
258 \VAR{foo
}. Applicable
\VAR{qualifier
}s depend on the
259 \kwd{method-combination
} type; see
260 section
\ref{section:Method Combination Types
}.
263 \IT{(
\xorGOO{\GFU*
{ADD-METHOD
}\\
264 \GFU*
{REMOVE-METHOD
}}{\
}} \VAR{generic-function
} \VAR{method
})
}
266 Add (if necessary) or remove (if any)
\VAR{method
} to/from
267 \retval{\VAR{generic-function
}}.
270 \IT{(
\GFU*
{FIND-METHOD
} \VAR{generic-function
} \VAR{qualifiers
}
271 \VAR{specializers
} \Op{\VAR{error
}\DF{\T}})
}
273 Return suitable
\retval{method
}, or signal
\kwd{error
}.
276 \IT{(
\GFU*
{COMPUTE-APPLICABLE-METHODS
} \VAR{generic-function
}
279 \retval{List of methods
} suitable for
\VAR{args
}, most specific first.
282 \IT{(
\FU*
{CALL-NEXT-METHOD
} \OPn{\VAR{arg
}}\DF{current args
})
}
284 From within a method, call next method with
\VAR{arg
}s; return
288 \IT{(
\GFU*
{NO-APPLICABLE-METHOD
} \VAR{generic-function
}
291 Called on invocation of
\VAR{generic-function
} on
\VAR{arg
}s if
292 there is no applicable method. Default method signals
\kwd{error
}.
295 \IT{(
\xorGOO{\FU*
{INVALID-METHOD-ERROR
} \VAR{ method
}\\
296 \FU*
{METHOD-COMBINATION-ERROR
}}{\
}}
297 \VAR{control
} \OPn{\VAR{arg
}})
}
299 Signal
\kwd{error
} on applicable method with invalid qualifiers, or
300 on method combination. For
\VAR{control
} and
\VAR{arg
}s see
301 \kwd{format
}, p.\
\pageref{section:Format
}.
304 \IT{(
\GFU*
{NO-NEXT-METHOD
} \VAR{generic-function
}
305 \VAR{method
} \OPn{\VAR{arg
}})
}
307 Called on invocation of
\kwd{call-next-method
} when there is no next
308 method. Default method signals
\kwd{error
}.
311 \IT{(
\GFU*
{FUNCTION-KEYWORDS
} \VAR{method
})
}
313 Return list of
\retval{keyword parameters
} of
\VAR{method
} and
314 \retvalii{\T} if other keys are allowed.
317 \IT{(
\GFU*
{METHOD-QUALIFIERS
} \VAR{method
})
}
319 \retval{List of qualifiers
} of
\VAR{method
}.
325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
326 \subsection[Method Combi- nation Types
]{Method Combination Types
}
327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
328 \label{section:Method Combination Types
}
333 Evaluate most specific
\kwd{:around
} method supplying the values of
334 the generic function. From within this method,
\FU{call-next-method
}
335 can call less specific
\kwd{:around
} methods if there are any. If
336 not, or if there are no
\kwd{:around
} methods at all, call all
337 \kwd{:before
} methods, most specific first, and the most specific
338 primary method which supplies the values of the calling
339 \FU{call-next-method
} if any, or of the generic function; and which
340 can call less specific primary methods via
341 \FU{call-next-method
}. After its return, call all
\kwd{:after
}
342 methods, least specific first.
348 \kwd*
{LIST
}\XOR \kwd*
{NCONC
}\XOR
354 Simple built-in
\kwd{method-combination
} types; have the same
356 \VAR{c-type
}s defined by the short form of
357 \MC{define-method-combination
}.
360 \IT{(
\MC*
{DEFINE-METHOD-COMBINATION
} \VAR{c-type
} \orGOO{%
361 \kwd{:documentation
} \NEV{\VAR{string
}}\\
362 \kwd{:identity-with-one-argument
} \VAR{ bool
}\DF{\NIL}\\
363 \kwd{:operator
} \VAR{ operator
}\DF{\VAR{c-type
}}}{\
}})
}
365 Short form. Define new
\kwd{method-combination
}
366 \retval{\VAR{c-type
}}. In a generic function using
\VAR{c-type
},
367 evaluate most specific
\kwd{:around
} method supplying the values of
368 the generic function. From within this method,
\FU{call-next-method
}
369 can call less specific
\kwd{:around
} methods if there are any. If
370 not, or if there are no
\kwd{:around
} methods at all,
371 have generic function applied to
\OPn{\VAR{gen-arg
}} return with the
372 values of (
\VAR{c-type
} \Goos{\VAR{primary-method
}
373 \OPn{\VAR{gen-arg
}}}), leftmost
\VAR{primary-method
} being the most
374 specific. In
\MC{defmethod
}, primary methods are denoted by the
375 \VAR{qualifier
} \VAR{c-type
}.
378 \IT{(
\MC*
{DEFINE-METHOD-COMBINATION
} \VAR{c-type
}
379 (
\OPn{\VAR{ord-$
\lambda$
}})
380 (
\OPn{(
\VAR{group
} \xorGOO{%
382 (
\OPn{\VAR{qualifier
}}\text{ } \OP{\kwd{\A}})\\
385 \kwd{:description
} \VAR{ control
}\\
387 \xorGOO{\kwd{:most-specific-first
}\\
388 \kwd{:most-specific-last
}}{\
}}\DF{\kwd{:most-specific-first
}}\\
389 \kwd{:required
} \VAR{ bool
}}{\
}})
})
391 (
\kwd{:arguments
} \OPn{\VAR{method-combination-$
\lambda$
}})\\
392 (
\kwd{:generic-function
} \VAR{ symbol
})\\
393 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\\
397 Long form. Define new
\kwd{method-combination
}
398 \retval{\VAR{c-type
}}. A call to a generic function using
399 \VAR{c-type
} will be equivalent to a call to the forms returned by
400 \OPn{\VAR{body
}} with
\OPn{\VAR{ord-$
\lambda$
}} bound to
401 \OPn{\VAR{c-arg
}} (cf.\
\MC{DEFGENERIC
}), with
\VAR{symbol
} bound to
402 the generic function, with
\OPn{\VAR{method-combination-$
\lambda$
}}
403 bound to the arguments of the generic function, and with
404 \VAR{group
}s bound to lists of methods. An applicable method becomes
405 a member of the leftmost
\VAR{group
} whose
\VAR{predicate
} or
406 \VAR{qualifier
}s match. Methods can be called via
407 \MC{CALL-METHOD
}. Lambda lists (
\OPn{\VAR{ord-$
\lambda$
}}) and
408 (
\OPn{\VAR{method-combination-$
\lambda$
}}) according to
409 \VAR{ord-$
\lambda$
} on p.\
\pageref{section:Functions
}, the latter
410 enhanced by an optional
\kwd{\&whole
} argument.
413 \IT{(
\MC*
{CALL-METHOD
} \xorGOO{\NEV{\VAR{method
}}\\
414 (
\MC*
{MAKE-METHOD
}\text{ } \NEV{\VAR{form
}})
}{\
}}%
416 \NEV{\VAR{next-method
}}\\
417 (
\MC*
{MAKE-METHOD
}\text{ } \NEV{\VAR{form
}})
}{\
}^
{\!\!*
}})
})
}
419 From within an effective method form, call
\VAR{method
} with the
420 arguments of the generic function and
421 with information about its
\VAR{next-method
}s; return
\retval{its
431 %%% TeX-master: "clqr"