This is a quick handout to help you with debugging macros.
If you're working with DrRacket, then there is a macro stepper button in
the toolbar. When you click it, you'll get a new window showing macro
expansion steps. Note that Racket itself is full of macros, so you'll
generally want to click the option to hide library macros. I'm not sure
that you can get it to work sanely though.
Another option is to use the Racket console REPL. Here's a rough sketch of
how you'd do it:
Open a terminal, and cd into the directory holding your file.
Start racket, the command-line REPL.
“enter” your file at the prompt:
> ,en myfile.rkt "myfile.rkt"> _
(It will go inside the context of the file and execute the code, kind of
like running the code in DrRacket, so expect some time for that to
(Note that it’s better to have small examples that focus only on the
macro you want to inspect. In this case, I entered a pushdown
expression, and not (define foo (pushdown ...)) so we focus on the
expansion of the macro and not whatever define expands to.)
This is now your “current” syntax. You can perform one expansion step by
entering ,stx +. If you enter it again, you get another expansion step
etc. You probably won’t need to go beyond the first step or few steps.
Note that for various resons, expanding this way might have some issues,
especially combined with typed racket, so you might run into inexplicable
type errors etc when you expand more steps. (And you’ll also see
expansion of internal stuff coming from the #lang pl etc.)