step
step Macro
Syntax:
step form → {result}*
Arguments and Values:
form—a form; evaluated as described below.
results—the values returned by the form.
Description:
step implements a debugging paradigm wherein the programmer is allowed to step through the evaluation of a form. The specific nature of the interaction, including which I/O streams are used and whether the stepping has lexical or dynamic scope, is implementation-defined.
step evaluates form in the current environment. A call to step can be compiled, but it is acceptable for an implementation to interactively step through only those parts of the computation that are interpreted.
It is technically permissible for a conforming implementation to take no action at all other than normal execution of the form. In such a situation, (step form) is equivalent to, for example, (let () form). In implementations where this is the case, the associated documentation should mention that fact.
See Also:
traceNotes:
Implementations are encouraged to respond to the typing of ? or the pressing of a “help key” by providing help including a list of commands.
Expanded Reference: step
Interactive stepping through evaluation
step evaluates a form in a stepping mode that allows the user to interactively control evaluation. The stepping interface is implementation-dependent.
;; Step through the evaluation of a form:
;; (step (+ 1 2 3))
;; The implementation provides an interactive stepper UI.
;; Eventually returns:
=> 6
Stepping through a function call
step is most useful for debugging complex expressions.
;; (step (mapcar #'1+ '(1 2 3)))
;; The stepper lets you step into each sub-evaluation.
;; Eventually returns:
=> (2 3 4)
Return value
step returns the values of the stepped form once stepping completes.
;; In non-interactive mode or after stepping through:
(step (values 1 2 3))
=> 1
=> 2
=> 3
Practical use at the REPL
step is primarily a development tool used at the REPL. It is not useful in non-interactive contexts. For non-interactive debugging, consider using trace instead.
;; Instead of step in scripts, use trace:
(trace +)
(+ 1 2 3)
; 0: (+ 1 2 3)
; 0: + returned 6
=> 6
(untrace +)