[plt-scheme] Macro stepper question
--- David Van Horn <dvanhorn at cs.brandeis.edu> wrote:
> Eli Barzilay wrote:
> > * DrScheme now has a macro stepper that traces through macro
> expansion
> > step by step. The graphical display uses colors to illustrate
> > bindings and a side-panel to display additional syntax
> information.
> > For additional information and an illustrated introduction, see
> > http://www.ccs.neu.edu/home/ryanc/macro-stepper
>
> When a macro expands into a use of another macro (potentially
> another instance of the original macro), the stepper seems to take
> the expansion of this macro as an atomic step rather than stepping
> through its expansion as well. This makes stepping through
> syntax-rules macros uninformative, at least for a style I
frequently
> use with syntax-rules.
> For example:
>
> (define-syntax rev
> (syntax-rules ()
> ((rev xs)
> (rev xs ()))
> ((rev () rxs)
> (quote rxs))
> ((rev (x . xs) rxs)
> (rev xs (x . rxs)))))
>
> (rev (3 2 1)) ;; => '(1 2 3)
>
> Stepping through this, I see:
>
> (rev (3 2 1))
> -> (rev (3 2 1) ())
> -> (quote (1 2 3))
Perhaps you're using the "Next term" button only, instead of the
"Step ->" button?
Go to the DrScheme buffer containing the definition and macro use,
and start the macro stepper.
It says "Expansion finished" for the macro definition. Click "Next
term" to move to the second term in the program, the macro use.
Now you see a step:
(rev (3 2 1))
=> Macro transformation
(rev (3 2 1) ())
You should use the "Step ->" button to see the expansion of the
program that the macro produces. Click "Step ->" and you'll see this
step:
(rev (3 2 1) ())
=> Macro transformation
(rev (2 1) (3))
Keep clicking "Step ->" until you get to the end of that expansion,
or click "End --->" to jump straight there.
When I do that, I see exactly what you said you expected to see,
except one step (a pair of terms) at a time. Does that work for you?
In summary: "Previous term" and "Next term" move between top-level
terms from DrScheme's definition window. "<- Step" and "Step ->" move
back and forth in the macro expansion process.
Ryan
PS - Thanks for the question! I'll clarify it in the manual and add
it to the macro stepper questions page.
>
> I'd like to see:
>
> (rev (3 2 1))
> -> (rev (3 2 1) ())
> -> (rev (2 1) (3))
> -> (rev (1) (2 3))
> -> (rev () (1 2 3))
> -> (quote (1 2 3))
>
> Is it possible to have the macro stepper perform the latter set of
> transformations?
>
> Thanks,
> David
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>