[racket] Single Step Evaluation in Racket

From: John Clements (clements at brinckerhoff.org)
Date: Thu Apr 24 01:53:37 EDT 2014

On Apr 23, 2014, at 10:03 PM, Zee Ken <udaybhasker552009 at gmail.com> wrote:

> Hi.
> 
> I just wanted to know the short-cut to do the single step evaluation in racket.
> 
> I want to know if there is anything analogous to adding watches in Turbo C for particular variable (to see how they change) and then hit F7 key to implement line by line execution.
> 
> Is there a way to do this racket?

Yes and no. 

Racket has two tools that might help you; the stepper, and the debugger. Each has advantages and disadvantages.

The stepper is useful in showing the steps taken during evaluation of programs written in the first four teaching languages. It’s useful in helping you to understand how a given language feature works.

The debugger is closer to what you’re asking for… but the fact is that the debugger isn’t very frequently used.  This is because when you write your code functionally, it’s generally more helpful to narrow down your problem using small test cases than by stepping through the code. Generally, single-stepping is most useful—as you correctly point out!—when your code is changing the values of variables. Racket programmers usually steer away from such solutions.

Best of luck!

John Clements



Posted on the users mailing list.