Macro
lispworks
defadvice (dspec name advice-type &key where documentation)
lambda-list &body body => nil
dspec ::= fn-name |
macro-name |
(method generic-fn-name [(class*)])
advice-type ::= :before |:after |:around
Specifies the functional definition to which the piece of advice belongs. There are three forms which this specification may take. The first one above specifies a function by its name; the second one specifies a macro by name; the third specifies a method by the name of its generic function and by a list of classes to specialize the arguments to the method. In the case of a method the list of classes must correspond exactly to the classes of the specialized parameters of an existing method, and the advice is then attached to this method.
When advice is provided for a macro usingdefadvice, then the function with which the advice is associated is the expansion function for that macro. Thus before and after advice for a macro receive the arguments given to the macro expansion function, which are normally the macro call form and an environment.
A symbol naming the piece of advice being created. It should of course be unique to the advised function, but does not need to be globally unique.
A keyword specifying the kind of advice wanted.
Specifies where this advice should be placed in the ordering of pieces of advice for the function. By default a piece of advice is placed at the start of the corresponding section. If this argument is present and is:end then the advice is instead placed at the end of its section. The other permissible value for this argument is:start, which places the advice at the start of its section in the ordering (as in the default behavior).
A string providing documentation on the piece of advice.
A lambda list for the piece of advice. In the case of before and after advice this should be compatible with the lambda-list for the original definition, since such advice receives the same arguments as that function.
The main body of the advice.
defadvice returnsnil. defadvice is the macro used to define a new piece of advice. Advice provides a way to change the behavior of existing functional definitions in the system. In a simple instance advice might be used to carry out some additional actions before or after the original definition. More sophisticated uses allow the definition to be replaced by new code that can access the original function repeatedly or as rarely as desired, and that can receive different numbers of arguments and return any values. A function may have any number of pieces of advice attached to it by usingdefadvice. call-next-advice. It may invoke this as often as it chooses, and by doing so it accesses the next piece of around advice if present, or else it accesses the combination of before and after advice together with the original definition. defadvice is an extension to Common Lisp.