This section shows you how to perform simple traces.
fac
into the listener:
(defun fac (n) (if (= n 1) 1 (* n (fac (- n 1)))))
(trace fac)
fac
as follows:
(fac 3)
The following trace output appears in the listener.
0 FAC > ... >> N : 3 1 FAC > ... >> N : 2 2 FAC > ... >> N : 1 2 FAC < ... << VALUE-0 : 1 1 FAC < ... << VALUE-0 : 2 0 FAC < ... << VALUE-0 : 6
Upon entry to each traced function call, trace prints the following information:
Each line is indented according to the level of tracing for the call.
>
denotes entry to a function, and >>
denotes an argument.
Upon exit from each traced function call, trace prints the following information:
<
denotes exit from a function, and <<
denotes a returned value.
Output produced in this way is always sent to a special stream, *trace-output*, which is either associated with the listener, or with background output.
Calling trace with no arguments produces a list of all the functions currently being traced. In order to cease tracing a function the macro untrace should be called with the function name. All tracing can be removed by calling untrace with no arguments.
CL-USER 5 > (untrace fac) (FAC) CL-USER 6 > (fac 4) 24 CL-USER 7 >
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:18