Next Previous Up Top Contents Index

4.2 Tracing options

4.2.1 Evaluating forms on entry to and exit from a traced function

:before

Trace keyword

:before list of forms

If non-nil, the list of forms is evaluated on entry to the function being traced. The forms are evaluated and the results printed after the arguments to the function.

Here is an example of its use.*traced-arglist* is bound to the list of arguments given to the function being traced. In this example, it is used to accumulate a list of all the arguments tofac across all iterations.

1. In the listener, initialize the variableargs-in-reverse as follows:
(setq args-in-reverse ())

2. For thefac function used earlier, set the value of:before to the following list:
((push (car *traced-arglist*) args-in-reverse))

3. In the listener, evaluate the following form:
(fac 3)

After evaluating this form,args-in-reverse has the value(1 2 3), that is, it lists the arguments whichfac was called with, in the reverse order they were called in.

:after

Trace keyword

:after list of forms

If non-nil, this option evaluates a list of forms upon return from the function to be traced. The forms are evaluated and the results printed after the results of a call to the function.
This option is used in exactly the same way as:before. For instance, using the example for:before as a basis, create a list calledresults-in-reverse, and set the value of:after so that(car *traced-results*) is pushed onto this list. After callingfac,results-in-reverse contains the results returned fromfac, in the reverse order they were called in.
Note:*traced-arglist* is still bound as well.

LispWorks User Guide - 14 Oct 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker