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{class-name
} (
\OPn{\VAR{superclass
}})
26 (
\OPn{\xorGOO{\VAR{slot
}\\
28 \orGOO{\Goos{\kwd{:reader
} \VAR{reader-fu
}}\\
29 \Goos{\kwd{:writer
} \VAR{writer-fu
}} \\
30 \Goos{\kwd{:accessor
} \VAR{reader-fu
}} \\
31 \kwd{:allocation
} \Goo{\kwd{:instance
}\XOR\kwd{:class
}}\\
32 \Goos{\kwd{:initarg
} \kwd{:
}\VAR{arg
}} \\
33 \kwd{:initform
} \VAR{ form
}\\
34 \kwd{:type
} \VAR{ type
}\\
35 \kwd{:documentation
} \VAR{ string
}}{\
}})
}{\
}}})
36 \orGOO{(
\kwd{:default-initargs
} \Goos{\VAR{name
}\VAR{ value
}})\\
37 (
\kwd{:documentation
} \VAR{ string
})\\
38 (
\kwd{:metaclass
} \VAR{ name
})
}{\
}})
}
40 Define
\retval{class
\VAR{ class-name
}} as a subclass of
\VAR{superclass
}es.
43 \IT{(
\FU*
{FIND-CLASS
} \VAR{symbol
} \OP{\VAR{errorp
}\DF{\T}
44 \Op{\VAR{environment
}}})
}
46 Return
\retval{class object
} named
\VAR{symbol
}.
\kwd{setf
}able.
49 \IT{(
\GFU*
{MAKE-INSTANCE
} \VAR{class
} \Goos{\kwd{:
}\VAR{initarg
}
50 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
52 Make new
\retval{instance of
\VAR{class
}}.
55 \IT{(
\GFU*
{INITIALIZE-INSTANCE
} (
\VAR{instance
}))
}
57 Its primary method sets slots on behalf of
58 \GFU*
{MAKE-INSTANCE
}. Return
\retval{instance
}.
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.
77 \IT{(
\MC*
{WITH-SLOTS
} (
\Goos{\VAR{slot
}\XOR(
\VAR{var
78 slot
})
})
\VAR{instance
} \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
81 Evaluate
\VAR{form
}s with slots of
\VAR{instance
} locally visible as
82 \VAR{slot
}s or
\VAR{var
}s.
85 \IT{(
\MC*
{WITH-ACCESSORS
} (
\OPn{(
\NEV{\VAR{var
}} \NEV{\VAR{accessor
}})
})
86 \VAR{instance
} \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
89 Evaluate
\VAR{form
}s with variables
\VAR{var
} locally bound to
90 \VAR{accessor
}s of
\VAR{instance
}.
91 Return
\retval{values of
\VAR{form
}s
}.
94 \IT{(
\GFU*
{CLASS-NAME
} \VAR{class
})
}
96 \retval{Name of
\VAR{class
}}.
\kwd{setf
}able.
99 \IT{(
\FU*
{CLASS-OF
} \VAR{foo
})
}
101 \retval{Class
} \VAR{foo
} is an instance of.
104 \IT{(
\GFU*
{CHANGE-CLASS
} \VAR{instance
} \VAR{new-class
} \Goos{\kwd{:
}\VAR{initarg
}
105 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
107 Change class of
\retval{\VAR{instance
}} to
\VAR{new-class
}.
110 \IT{(
\GFU*
{UPDATE-INSTANCE-FOR-DIFFERENT-CLASS
} \VAR{previous
}
111 \VAR{current
} \Goos{\kwd{:
}\VAR{initarg
}
112 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
114 Called by
\GFU{change-class
}.
117 \IT{(
\GFU*
{MAKE-INSTANCES-OBSOLETE
} \VAR{class
})
}
119 Update instances of
\VAR{class
}.
122 \IT{(
\GFU*
{UPDATE-INSTANCE-FOR-REDEFINED-CLASS
} \VAR{instances
}
123 \VAR{added-slots
} \VAR{discarded-slots
} \VAR{property-list
}
124 \Goos{\kwd{:
}\VAR{initarg
}
125 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
127 Called by
\GFU{make-instances-obsolete
}.
130 \IT{(
\GFU*
{SHARED-INITIALIZE
} \VAR{instance
} \VAR{slots
}
131 \Goos{\kwd{:
}\VAR{initarg
}
132 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
134 Fill
\VAR{instance
}'s
\VAR{slots
} using
\VAR{init-args
} and
135 \kwd{:initform
} forms.
138 \IT{(
\GFU*
{SLOT-MISSING
} \VAR{class
} \VAR{object
} \VAR{slot
}
141 \kwd{slot-makunbound
}}{\
}}
144 Called in case of attempted access to missing
\VAR{slot
}. Default primary
145 method signals
\kwd{error
}.
148 \IT{(
\GFU*
{SLOT-UNBOUND
} \VAR{class
} \VAR{instance
} \VAR{slot
})
}
150 Called by
\FU{slot-value
} in case of unbound
\VAR{slot
}. Default primary
151 method signals
\kwd{unbound-slot
}.
157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158 \subsection{Generic Functions
}
159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
162 \IT{(
\FU*
{NEXT-METHOD-P
})
}
164 \retval{\T} if enclosing method has a next method.
167 \IT{(
\MC*
{DEFGENERIC
}
168 \xorGOO{\VAR{name
}\\ (
\kwd{setf
} \VAR{ name
})
}{\
}}
170 \OP{\kwd*
{\&optional
} \Goos{\VAR{var
}\XOR(
\VAR{var
})
}}
171 \OP{\kwd*
{\&rest
} \VAR{var
}}
172 \OP{\kwd*
{\&key
} \orGOO{%
174 (
\VAR{var
}\XOR(
\kwd{:
}\VAR{key
}
175 \VAR{var
}))
}{\
}^
{\!\!*
}} \Op{\kwd*
{\&allow-other-keys
}}})
177 (
\kwd{:argument-precendence-order
}\RP{\VAR{ var
}})\\
178 (
\kwd{declare
}\RP{(
\kwd{optimize
}\OPn{\VAR{ arg
}})
})\\
179 (
\kwd{:documentation
} \NEV{\VAR{string
}})\\
180 (
\kwd{:generic-function-class
} \VAR{ class
}\DF{\kwd{standard-generic-function
}})\\
181 (
\kwd{:method-class
} \VAR{ class
}\DF{\kwd{standard-method
}})\\
182 (
\kwd{:method-combination
} \VAR{ c-type
} \OPn{\VAR{ arg
}})\\
183 \OPn{(
\kwd{:method
} \VAR{ defmethod-arguments
})
}}{\
}})
}
185 Define
\retval{generic function
\VAR{name
}}. For
\VAR{c-type
} see
186 s.\
\ref{section:Method Combination Types
}.
189 \IT{(
\FU*
{ENSURE-GENERIC-FUNCTION
}
190 \xorGOO{\VAR{name
}\\ (
\kwd{setf
} \VAR{ name
})
}{\
}}
192 \kwd{:argument-precendence-order
}\RP{\VAR{ arg
}}\\
193 \kwd{:declare
}\RP{(
\kwd{optimize
}\OPn{\VAR{ arg
}})
}\\
194 \kwd{:documentation
} \VAR{ string
}\\
195 \kwd{:environment
} \VAR{ environment
}\\
196 \kwd{:generic-function-class
} \VAR{ class
}\\
197 \kwd{:lambda-list
} \VAR{ lambda-list
}\\
198 \kwd{:method-class
} \VAR{ class
}\\
199 \kwd{:method-combination
} \VAR{ c-type
} \OPn{\VAR{ arg
}}}{\
}})
}
201 Define or modify
\retval{generic function
\VAR{name
}}. For
\VAR{c-type
} see
202 s.\
\ref{section:Method Combination Types
}.
206 \xorGOO{\VAR{bar
}\\ (
\kwd{setf
} \VAR{ bar
})
}{\
}}
207 \Op{\xorGOO{\kwd{:before
}\\
211 (
\VAR{spec-var
} \xorGOO{\VAR{class
}\\
212 (
\kwd{eql
} \VAR{ foo
})
}{\
}})
}{\
}^
{\!\!*
}}
213 \OP{\kwd*
{\&optional
} \Goos{\VAR{var
}\XOR(
\VAR{var
} \OP{\VAR{init
}
214 \Op{\VAR{supplied-p
}}})
}}
215 \Op{\kwd*
{\&rest
} \VAR{var
}}
216 \OP{\kwd*
{\&key
} \GOos{\VAR{var
}\XOR(
\Goo{\VAR{var
}\XOR(
\kwd{:
}\VAR{key
}
218 \OP{\VAR{init
}\Op{\VAR{supplied-p
}}})
}
219 \Op{\kwd*
{\&allow-other-keys
}}}
220 \OP{\kwd*
{\&aux
}\Goos{\VAR{var
}\XOR(
\VAR{var
} \Op{\VAR{init
}})
}})
221 \orGOO{\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\\
222 \NEV{\VAR{documentation
}}}{\
}}
225 Define
\retval{new method
} for generic function
226 \VAR{bar
}.
\VAR{spec-var
}s specialize to either being of
\VAR{class
}
227 or being
\kwd{eql
} \VAR{foo
}, respectively. On invocation,
\VAR{var
}s and
228 \VAR{spec-var
}s of the
\retval{new method
}
229 act like parameters of a function with body
\OPn{\VAR{form
}}.
232 \IT{(
\xorGOO{\GFU*
{ADD-METHOD
}\\
233 \GFU*
{REMOVE-METHOD
}}{\
}} \VAR{generic-function
} \VAR{method
})
}
235 Add, or remove, respectively,
\VAR{method
} from
\retval{\VAR{generic-function
}}.
238 \IT{(
\FU*
{CALL-NEXT-METHOD
} \OPn{\VAR{args
}}\DF{current args
})
}
240 From within a method, call next method with
\VAR{arg
}s; return
244 \IT{(
\MC*
{CALL-METHOD
} \orGOO{\NEV{\VAR{method
}}\\
245 (
\MC*
{MAKE-METHOD
} \VAR{ form
})
}{\
}}
246 \Op{\NEV{\VAR{next-methods
}}})
}
248 Call
\VAR{method
}, return
\retval{its values
}.
251 \IT{(
\GFU*
{NO-APPLICABLE-METHOD
} \VAR{generic-function
}
254 Called on invocation of
\VAR{generic-function
} if there is no applicable method.
257 \IT{(
\xorGOO{\FU*
{INVALID-METHOD-ERROR
} \VAR{ method
}\\
258 \FU*
{METHOD-COMBINATION-ERROR
}}{\
}}
259 \VAR{control
} \OPn{\VAR{arg
}})
}
261 Signal
\kwd{error
} on applicable method, or on method combination,
262 with invalid qualifiers. For
\VAR{control
} and
\VAR{arg
}s see
263 \kwd{format
}, p.\
\pageref{section:Format
}.
266 \IT{(
\GFU*
{NO-NEXT-METHOD
} \VAR{generic-function
}
267 \VAR{method
} \OPn{\VAR{arg
}})
}
269 Called on invocation of
\kwd{call-next-method
} if there is no next method.
272 \IT{(
\GFU*
{FUNCTION-KEYWORDS
} \VAR{method
})
}
274 Return list of
\retval{keyword parameters
} of
\VAR{method
} and
275 \retvalii{\T} of other keys are alowed.
278 \IT{(
\GFU*
{ALLOCATE-INSTANCE
} \VAR{class
} \Goos{\kwd{:
}\VAR{initarg
}
279 \VAR{value
}} \OPn{\VAR{other-keyarg
}})
}
281 Return uninitialized
\retval{instance
} of
\VAR{class
}.
284 \IT{(
\GFU*
{METHOD-QUALIFIERS
} \VAR{method
})
}
286 List of qualifiers of
\VAR{method
}.
289 \IT{(
\GFU*
{FIND-METHOD
} \VAR{generic-function
} \VAR{qualifiers
}
290 \VAR{specializers
} \Op{\VAR{error
}\DF{\T}})
}
292 Return suitable
\retval{method
}, or signal
\kwd{error
}.
295 \IT{(
\GFU*
{COMPUTE-APPLICABLE-METHODS
} \VAR{generic-function
}
298 \retval{List of methods
} suitable for
\VAR{args
}, most specific first.
304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
305 \subsection{Method Combination Types
}
306 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
307 \label{section:Method Combination Types
}
310 \IT{\arrGOO{\kwd*
{AND
}\\
320 Built-in method combination types.
325 Standard method combination type, also used if no method combination
329 \IT{(
\MC*
{DEFINE-METHOD-COMBINATION
} \VAR{c-type
} \orGOO{%
330 \kwd{:documentation
} \NEV{\VAR{string
}}\\
331 \kwd{:identity-with-one-argument
} \VAR{ bool
}\DF{\NIL}\\
332 \kwd{:operator
} \VAR{ operator
}\DF{\VAR{c-type
}}}{\
}})
}
334 Short form. Define new method combination type
335 \retval{\VAR{c-type
}}. A call to a generic function using
336 \VAR{c-type
} will be equivalent to (
\VAR{c-type
}
337 \OPn{\VAR{applicable-method
}}).
340 \IT{(
\MC*
{DEFINE-METHOD-COMBINATION
} \VAR{c-type
}
342 (
\GOOs{\VAR{name
} \xorGOO{%
343 \GOOp{\VAR{list
}\XOR\kwd{*
}}\\
344 \VAR{predicate
}}{\
}} \orGOO{%
345 \kwd{:description
} \VAR{ control
}\\
347 \Goo{\kwd{:most-specific-first
}\XOR\kwd{:most-specific-last
}}\\
348 \kwd{:required
} \VAR{ bool
}}{\
}}})
349 \Op{\kwd{:arguments
} (
\OPn{\VAR{method-combination-arg
}})
}
350 \Op{\kwd{:generic-function
} \VAR{ symbol
}}
351 \orGOO{\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\\
352 \NEV{\VAR{documentation
}}}{\
}}
355 Long form. A call to a generic function using
\VAR{c-type
} will be
356 equivalent to a call to the forms returned by
\VAR{body
}. Lambda
357 lists (
\OPn{\VAR{fu-arg
}}) and (
\OPn{\VAR{method-combination-arg
}})
358 according to
\VAR{fu-arg
} on p.\
\pageref{section:Functions
}, the
359 latter enhanced by an optional
\kwd{\&whole
} argument.