This minitutorial discusses several topics:

Invoking the MCL Stepper

The MCL stepper allows you to step through the evaluation of a S-expression one step at a time. It can, at the very least, help you comprend the Lisp evaluation model better. It can also be a very useful tool when you code seems to have a mind of it's own. :-)

To use the stepper with the compiler turned on you have to set the *save-definitions* variable to T. If not the stepper will have no source code to step through. You press the "Step" button and the stepper will tell you the "answer". If you have opened and evaluated the file init.lisp then you should be OK.

Once the stepper is invoked the Steeper Window will appear. The top pane of this window has five buttons:

	Quit		Eval		Go	Step Over	Step

   Quit      -- quit the stepping 
   Eval      -- opens a dialog box in which you can type in any lisp form to
                evaluate in the current lexical environment.
   Go        -- Complete evaluation without stepping.
   Step Over -- Do not step through the next subexpression.
   Step      -- Step to next expression to evaluate.
The step button is the "Default" button so if you hitting the Return key has the same effect as clicking on that button.

Stepping through an example

We'll need an example function to step through. You can step through any S-expression, like ( if t (1+ 2 ) (1+ 3) ) but that isn't very interesting. The following function is slightly more interesting.
  (defun step-me ( int num-times result )
    (cond ((= num-times 0 ) result )
          ((= num-times 1 ) result )
          (t (step-me int (1- num-times ) (+ int result )))))
Enter and evaluate this function. Next Evaluate the following in the Listener Window.
      ? (step  (step-me  3 5 0 ))
This will open the MCL Stepper Window. The buttons do the fairly obvious if you've ever used a graphical debugger before for a procedural language. [ They kind of remind me of the insanely great debugger in Think Pascal with the Instant Window... more on that later. ]

If you press the step button once you will cause the stepper to start to evaluate the function. If you press "step" a couple more times you will see the cond S-expression incrementally evaluated. The "step over" button will allows you to step over an "other" function you might have called. [ The stepper will not step into any of the builtin functions. They work. :-) ]

If your code contains a break ( see the debbuger tutorial ), then you may press the go button and evaluation will continue until the break is reach or the evaluation is complete, whichever comes first. Unfortunately, you cannot go back into step mode after continuing from the break. See the

Looking inside the lexical scope

Now let's reinvoke the stepper again. But before doing anything, press the "Eval" button. This will bring up a dialog box for you to type an S-expression in [ shades of the Think Pascal Instant Window. ]. You may simply type num-times here. It will answer 5 since in the beginning num-times has been bound to 5 so that the body of the function by be evaluated.

This capability can come in handy when you have stepped into an errant function and you are trying to decide what you should change to code to really do. You can try out evaluating certain S-expressions to confirm to yourself what you should have wrote in the first place.... it happens to all of us. :-)

What else can I do?

I'm sure at this point you can think of even more uses for this tool that you wished you knew about 3 Homeworks ago. To learn more about using MCL to help decipher your homework code see the debugging and tracing minitutorials.
Back to MCL and Tool Time

Last modified: by Lyman S. Taylor(lyman@cc.gatech.edu)
(c) copyright Lyman S. Taylor 1995, All rights reserved