I am using Dr. Racket and Racket for educational purposes (studying the SICP book). Dr. Racket is great and it has an awesome tool called "trace".
After using:
(require trace/racket)
(trace function)
It is possible to see what is happening in a recursive procedure.
However, this feature does not work with iterative procedures. I wish I could "see" what's happening in my code while it is being executed. I wish I could see the change in values of the state variables.
Is there an alternative tool or practice to have that kind of information in an iterative procedure?
Tracing is not debugging. In DrRacket you press the DEBUG button and right click on the edge of interesting parts, like a
ifthat determines base case or defautl case in a helper and choose "Pause at this point". Then everytime you hit Go you can see the bound arguments a step at a time.If you want to just trace you can trace a helper like this:
If you want to use named
letjust replace it withtrace-let:Using the debugger is much faster than having to add lines and remove lines in code in order to test it.