[plt-scheme] Proposal for s-expr tracing format

From: Shriram Krishnamurthi (sk at cs.brown.edu)
Date: Sun Aug 12 11:20:15 EDT 2007

I think this is a great idea!

I wrote the first version of trace to dumbly mimic the version in Chez
Scheme (which in turn probably minicked the one in ..., which ...,
which probably goes back to Lisp 1.5 or something).  But this is
definitely superior.

There's no reason it can't print the way you want it to.  Indeed, if
you're willing to settle for not handling multiple-values and having
superfluous newlines, here's a diff that you can apply to
./collects/mzlib/trace.ss to get parenthetical printing (though not
precisely in the format you specified):

44c44
<                (first '(""))
---
>                (first '("|"))
63c63
<                        (cons "  " first)
---
>                        (cons " |" first)
94d93
<         (pretty-display "(")
118,119c117
<           (pretty-print (car results))
<           (pretty-display ")"))
---
>           (pretty-print (car results)))

This even gives you existing indentation level, so you don't even need
to copy and re-indent the output.

A better solution would be to have a parameter that leaves the default
alone, and uses your described behavior when the parameter is set.
When that is set, the zero-return-value case should print something
that is syntactically an s-expression (like 'no-return-values), AND
the special depth checker (which prefixes calls deeper than a
prescribed depth -- defaulting to 10 -- with a depth counter of the
form [<depth>], eg, [10]) should be turned off, to keep the
s-expression clean and simple.

Shriram


Posted on the users mailing list.