Up | Next | Prev | PrevTail | Tail |
One often needs information about the internal behaviour of a procedure, especially if
it is a longer piece of code. For an interpreted procedure declared in an rtrst
command:
rtrst <proc1>, <proc2>, ..., <procn>;
all explicit assignments executed (as either the symbolic-mode setq
or the
algebraic-mode setk
) inside these procedures are displayed during procedure
execution. All procedure tracing (assignment and entry-exit) is removed by the command
unrtrst
(or unrtr
, for which it is just a synonym):
unrtrst <proc1>, <proc2>, ..., <procn>;
Assignment tracing is not possible if a procedure is compiled, either because it was loaded from a “fasl” file or image, or because it was compiled as it was read in as source code. This is because assignment tracing works by modifying the interpreted code of the procedure, which must therefore be available.
Applying rtr
to a procedure that has been declared in an rtrst
command, or
vice versa, toggles the type of tracing applied (and displays an explanatory
message).
Note that when a program contains a for
loop, REDUCE translates this to a sequence of
Lisp instructions. When using rtrst
, the printout is driven by the “unfolded” code.
When the code contains a for each … in
statement, the name of the control variable
is internally used to keep the remainder of the list during the loop, and you will see the
corresponding assignments in the trace rather than the individual values in the loop steps,
e.g.
procedure fold u; for each x in u sum x$ rtrst fold; (fold) fold {z, z*y, y};
produces the following output (using CSL-REDUCE):
Enter (1) fold u: {z,y*z,y}$ x := [z,y*z,y]$ G0 := 0$ G0 := z$ x := [y*z,y]$ G0 := z*(y + 1)$ x := [y]$ G0 := y*z + y + z$ x := []$ Leave (1) fold = y*z + y + z$ y*z + y + z unrtrst fold; (fold)
In this example, the printed assignments for x
show the various stages of the loop. The
variable G0
is an internally generated place-holder for the sum, and may have a slightly
different name depending on the underlying Lisp systems.
Up | Next | Prev | PrevTail | Front |