Last night I found "A Better API for First-Class Continuations", which explains how a debugger can take control and give it back to the original computation. The paper also describes the tree created by a series of continuations. Is there a way to see the whole tree? I'd like to under- stand how the backtrace command creates the stack out of the tree.
You need a first error or step to show a backtrace. As the transcript below shows, a second error will change the backtrace (I had hoped it would add frames to the printout). Curiously the change is only temporary -- "undoing" the second error with ,d also undoes the change. As the second test shows, tail recursion is not involved. I assume the "change" is really an effect of the ,b printing code.
Thanks!
-- Derek
Gambit v4.2.4
(define (a) ; a (step) in tail position doesn't cause a stop -- doubling
(step) (step)) ; creates a non-tail (step) which is what the test uses
(a)
*** STOPPED IN a, (console)@2.9 1> ,b 0 a (console)@2:9 step 1 (interaction) (console)@3:1 (a) 1> x *** ERROR IN (console)@5.1 -- Unbound variable: x 2> ,b 0 (interaction) (console)@5:1 x 1 (interaction) (console)@3:1 (a) 2> ,d 1> ,b 0 a (console)@2:9 step 1 (interaction) (console)@3:1 (a) 1> ,q
Gambit v4.2.4
(generate-proper-tail-calls #f) (define (a)
(step) (step))
(a)
*** STOPPED IN a, (console)@3.9 1> ,b 0 a (console)@3:9 step 1 (interaction) (console)@4:1 (a) 1> x *** ERROR IN (console)@6.1 -- Unbound variable: x 2> ,b 0 (interaction) (console)@6:1 x 1 (interaction) (console)@4:1 (a) 2> ,d 1> ,b 0 a (console)@3:9 step 1 (interaction) (console)@4:1 (a) 1> ,q
Afficher les réponses par date
Here's what happens if I run the same tests with ##show-all-continuations? set to true. Level 2 adds frames to the backtrace without changing any of level 1's frames. Much more straightforward. Now I don't need so badly to see the continuation tree.
With the line "(generate-proper-tail-calls #f)" added, the results are the same except for line numbers.
-- Derek
Gambit v4.2.4
(set! ##show-all-continuations? #t) (define (a)
(step) (step))
(a)
*** STOPPED IN a, (console)@3.9 1> ,b 0 a (console)@3:9 step 1 a (console)@3:8 (step) 2 (interaction) (console)@4:1 (a) 3 ##eval-within 4 ##dynamic-env-bind 5 ##with-no-result-expected 6 ##repl-debug 7 ##repl-debug-main 8 ##kernel-handlers 1> x *** ERROR IN (console)@6.1 -- Unbound variable: x 2> ,b 0 (interaction) (console)@6:1 x 1 ##eval-within 2 ##dynamic-env-bind 3 a (console)@3:9 step 4 a (console)@3:8 (step) 5 (interaction) (console)@4:1 (a) 6 ##eval-within 7 ##dynamic-env-bind 8 ##with-no-result-expected 9 ##repl-debug 10 ##repl-debug-main 11 ##kernel-handlers 2> ,d 1> ,b 0 a (console)@3:9 step 1 a (console)@3:8 (step) 2 (interaction) (console)@4:1 (a) 3 ##eval-within 4 ##dynamic-env-bind 5 ##with-no-result-expected 6 ##repl-debug 7 ##repl-debug-main 8 ##kernel-handlers 1> ,q