[plt-scheme] Suggestion: Backtrace Remembers Last, not First Tail-Recursive Procedure

From: Synx (plt at synx.us.to)
Date: Fri Apr 9 04:20:16 EDT 2010

I think I figured it out. It should have been slapping me in the face
the whole time. The "main" procedure is /not/ tail recursive. I thought
it was. So the scheme interpreter /does/ do the proper behavior of
discarding the procedures optimized out by tail calls, from
"with-transaction", to that loop in sqlite.ss, only retaining the last
one on the stack. I thought it was artificially preserving the first
procedure, main, when in reality main was just an ordinary
non-tail-recursive stack frame, and beyond that it had been properly
preserving only the last procedure called (or last iteration of the loop
before an exception was raised).

>  === context ===
> /home/*****/.plt-scheme/planet/300/4.2.4/cache/jaymccarthy/sqlite.plt/4/6/sqlite.ss:59:0:
> sqlite-error
> /home/*****/.plt-scheme/planet/300/4.2.4/cache/jaymccarthy/sqlite.plt/4/6/sqlite.ss:186:0:
> step
> /var/opt/plt/lib/plt/collects/scheme/contract/private/arrow.ss:1388:3
> /home/*****/code/scheme/util/sqlite.ss:80:9: loop
> /home/*****/code/scheme/backup/scan.ss:56:0: main

Still haven't found the bug yet, but I think that's a better way to read
the stack trace, that no error occurred outside of the procedure at
sqlite.ss:80:9, even though there were tail recursive procedures calling
it, not counting "main".

Posted on the users mailing list.