[racket] inspect variable values in backtrace?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Mar 2 11:20:28 EST 2011

Create a file 'debug.rkt' in your collects. 

It provides a single function: 

 ;; tee : X Y -> Y 

(define (tee tag val)
  (displayln `(,tag ,val))

When you wish to debug, require debug,rkt and wrap questionable expressions with (tee 'whatdoesitdo some-xpr)

On Mar 2, 2011, at 11:16 AM, Fred G. Martin wrote:

> Thanks.
> I figured out how to put printf's into my core predicate, using begin
> (followed by my predicate-expression).  It turned out that the 3rd (of
> the ca. 500) items in my hash table first exercised my error, so now
> I'm on my way to fixing it.
> Is this what other people do?  Is there a more elegant way?  I guess
> printf's are universal?
> Fred
> On Wed, Mar 2, 2011 at 9:07 AM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
>> The backtrace does not include that information. However, the
>> graphical debugger built in DrRacket will do what you'd like. Using it
>> can be very time consuming though because it works by annotating your
>> program and then running it with many more additional operations. Most
>> of my students swear by it (although I have a hard time remembering to
>> try it since it wasn't there when I started with Racket.)
>> Jay
>> 2011/3/2 Fred G. Martin <fredm at cs.uml.edu>:
>>> Hi all,
>>> Is it possible to see the bindings of various things in a backtrace?  I am
>>> having trouble debugging my code because I'm not sure which input is causing
>>> it to fail -- at some point, I'm trying to take the car of an empty list.
>>>  The outer thing is a for-each mapping over a hash table with about 500
>>> entries, and I'm not sure which entry is causing my inner stuff to break.
>>> Can't use printf, right?... any advice?
>>> thanks,
>>> Fred
>>> _________________________________________________
>>>  For list-related administrative tasks:
>>>  http://lists.racket-lang.org/listinfo/users
>> --
>> Jay McCarthy <jay at cs.byu.edu>
>> Assistant Professor / Brigham Young University
>> http://faculty.cs.byu.edu/~jay
>> "The glory of God is Intelligence" - D&C 93
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

Posted on the users mailing list.