Each change that is required should be specified using the defadvice macro. This defines a new body of code to be used when the function is called; this piece of code is called a piece of advice. Consider the following example:
(capi:prompt-for-file pff-1 :before)
(message &key &allow-other-keys)
(format t "~&Prompting for file with message ~S~%" message))
Here defadvice is given a description of the function you want to alter, a name for the piece of advice, and the keyword
to indicate that you want the code carried out before
is called. The rest of the call to defadvice specifies the additional behavior required, and consists of the lambda list for the new piece of advice and its body (the lambda list may specify keyword parameters and so forth). The advice facility arranges that pff-1 is invoked whenever
is called, and that it receives the arguments to
, and that directly after this the original definition of
After executing this advice definition, demonstrate it by selecting the menu command File > Open in the LispWorks IDE. The message appears in the Output tab.
Pieces of advice may be given to be executed after the call by specifying
in the call to defadvice. So if you wished to add further code to be performed after
you could also define:
(capi:prompt-for-file pff-2 :after)
(message &rest args)
"~&The other arguments to prompt-for-file were: ~S~%"
also receives the arguments to
, which are reported by the body.
LispWorks User Guide and Reference Manual - 21 Dec 2011