(step expression)expression step by step.
Interaction with user will be done in the following circumstances.
Eval: expression ?
expression.
The following commands may be used.
| (enter) | Continue stepping. |
n |
Execute normally until expression
returns a value. |
r |
Prompted for expression.
The input will be evaluated in the top level environment and used
in place of value of expression. |
e |
Prompted for expression.
The input will be evaluated in the same environment with
expression and resulting value is displayed. |
b |
Execute (break). |
Tail recursion: expression ?
expression in
the circumstance of tail recursion.
The same commands with Eval: may be used.
Return: value ?
value.
The following commands may be used.
| (enter) | Continue stepping. |
r |
Prompted for expression.
The input will be evaluated in the top level environment and
used in place of value. |
b |
Execute (break). |
pi: (step (tak 3 2 1)) Eval: (tak 3 2 1) ? ? step n}ext r}eturn e}val b}reak Eval: (tak 3 2 1) ? Eval: tak ? Return: #<020383F8> ? Eval: 3 ? Return: 3 ? Eval: 2 ? Return: 2 ? Eval: 1 ? Return: 1 ? Tail recursion: (if (not (< y x)) z (tak (tak (- x 1) y z) (tak (- y 1) z x) (tak (- z 1) x y))) ? ? step n}ext r}eturn e}val b}reak Tail recursion: (if (not (< y x)) z (tak (tak (- x 1) y z) (tak (- y 1) z x) (tak (- z 1) x y))) ? Eval: if ? Return: #<0202AA40> ? Eval: (not (< y x)) ? n Return: #f ? ? step r}eturn b}reak Return: #f ? Tail recursion: (tak (tak (- x 1) y z) (tak (- y 1) z x) (tak (- z 1) x y)) ? e Expression? x 3 Tail recursion: (tak (tak (- x 1) y z) (tak (- y 1) z x) (tak (- z 1) x y)) ? e Expression? y 2 Tail recursion: (tak (tak (- x 1) y z) (tak (- y 1) z x) (tak (- z 1) x y)) ? Eval: tak ? Return: #<020383F8> ? Eval: (tak (- x 1) y z) ? e Expression? z 1 Eval: (tak (- x 1) y z) ? b break> (continue) Eval: (tak (- x 1) y z) ? n Return: 1 ? r Value? 2 Eval: (tak (- y 1) z x) ? r Value? 1 Eval: (tak (- z 1) x y) ? Eval: tak ? Return: #<020383F8> ? Eval: (- z 1) ? n Return: 0 ? Eval: x ? Return: 3 ? Eval: y ? Return: 2 ? Tail recursion: (if-parsed (not (< y x)) z (tak (tak (- x 1) y z) (tak (- y 1) z x) (tak (- z 1) x y))) ? n Return: 2 ? Tail recursion: (if-parsed (not (< y x)) z (tak (tak (- x 1) y z) (tak (- y 1) z x) (tak (- z 1) x y))) ? Eval: (not (< y x)) ? Eval: (< y x) ? Eval: y ? Return: 1 ? Eval: x ? Return: 2 ? Return: #t ? Return: #f ? Tail recursion: (tak (tak (- x 1) y z) (tak (- y 1) z x) (tak (- z 1) x y)) ? r Value? 'foo Return: foo ? foo pi: (step (let ((x 0) (y 1)) (cons x y))) Eval: (let ((x 0) (y 1)) (cons x y)) ? Eval: let ? Return: #<000884A8> ? Tail recursion: ((lambda (x y) (cons x y)) 0 1) ? Eval: (lambda (x y) (cons x y)) ? Eval: lambda ? Return: #<00088468> ? Tail recursion: (rp:lambda (x y) (cons x y)) ? Eval: rp:lambda ? Return: #<100FC0B8> ? Return: #<0009AE90> ? Eval: 0 ? Return: 0 ? Eval: 1 ? Return: 1 ? Tail recursion: (cons x y) ? Eval: cons ? Return: #<100FBA18> ? Eval: x ? Return: 0 ? Eval: y ? Return: 1 ? Return: (0 . 1) ? (0 . 1)
(trace function-name ...)function-name
to display arguments and value on entrance and return respectively.
Because on scheme, precedures often does not return,
call frame is displayed not via indent, but serial number is used instead.
Example
pi: (trace tak) #<done> pi: (tak 3 2 1) <0>Call: (tak 3 2 1) <1>Call: (tak 2 2 1) <1>Return: 1 <2>Call: (tak 1 1 3) <2>Return: 3 <3>Call: (tak 0 3 2) <3>Return: 2 <4>Call: (tak 1 3 2) <4>Return: 2 <0>Return: 2 2
(trap function-name ...)trace does display only,
trap does interaction with user
at each time procedure is called. No display is done at return time, and so
normal execution can be done even if program contains iteration via tail
recursion.
Call: (function . args) ?
Function is about to be called.
The following commands may be used.
| (enter) | Continue execution. |
s |
Enter stepping mode. |
r |
Prompted for expression. The input will be evaluated in the top level environment and used in place of return value. |
b |
Execute (break). |
pi: (trap tak) #<done> pi: (tak 3 2 1) Call: (tak 3 2 1) ? Call: (tak 2 2 1) ? Call: (tak 1 1 3) ? ? pass s}tep r}eturn b}erak Call: (tak 1 1 3) ? b break> (continue) Call: (tak 1 1 3) ? s Eval: (if-parsed (not (< y x)) z (tak (tak (- x 1) y z) (tak (- y 1) z x) (tak (- z 1) x y))) ? Eval: (not (< y x)) ? n Return: #t ? Tail recursion: z ? Return: 3 ? Call: (tak 0 3 2) ? Call: (tak 1 3 2) ? r Value? -1 -1
(untrace function-name ...)trace, trap.
(trace-error expression)trace-error. But it is at the big cost of execution time.
frame ?
| (enter) | Display parent frame. |
e |
Prompted for expression.
The input will be evaluated in the same environment with
frame and resulting value is displayed. |
b |
Execute (break). |
a |
Diaplay entire frames. |
q |
Quit display of backtrace. |
$err and can be redisplayed by (backtrace $err).
(Of cource, the value of $err may be assigned to any variable
or such at your will.)
Example
pi: (define (len1 l) (if (null? l) 0 (+ (len1 (cdr l)) 1))) #<done> pi: (trace-error (len1 '(1 2 3 . 4))) Illegal argument supplied to function Backtrace: (cdr l) ? ? parent e}val b}reak a}ll q}uit (cdr l) ? e Expression? l 4 (cdr l) ? (len1 (cdr l)) ? =tail-recursion=> (+ (len1 (cdr l)) 1) ? (len1 (cdr l)) ? =tail-recursion=> (+ (len1 (cdr l)) 1) ? e Expression? l (3 . 4) =tail-recursion=> (+ (len1 (cdr l)) 1) ? (len1 (cdr l)) ? e Expression? l (2 3 . 4) (len1 (cdr l)) ? b break> (continue) (len1 (cdr l)) ? a =tail-recursion=> (+ (len1 (cdr l)) 1) (len1 (cdr l)) =tail-recursion=> (+ (len1 (cdr l)) 1) (len1 (quote-parsed 1 2 3 . 4)) #f pi: (trace-error (len1 '(1 2 3 4 5 6 7 8 . 9))) Illegal argument supplied to function Backtrace: (cdr l) ? e Expression? l 9 (cdr l) ? q #f