Where is macroexpand in Scheme?
Thursday, November 6, 2003
I wanted to expand a macro in Scheme today. I had a look for "macroexpand" in R5RS and the PLT documenation. Didn't find it. At least, not in R5RS. In PLT Scheme, the following code seems to be roughly equivalent to macroexpand:
(syntax-object->datum (expand-to-top-form '(some-macro some-params)))Seems odd that there isn't some more convenient way to do a macro expansion.
Also, I came up with the following questions:
- Is the "(syntax-object->datum (expand-to-top-form" approach what everyone uses to expand macros? It seems like there would be a "macroexpand" (or equivalent) as a standard extension in different Scheme implementations (yes, I know how to create a macroexpand macro if I want one).
- What are some things that people do with a syntax object (e.g. -- the thing you get when you do an expand or expand-to-top-form)? They seem like interesting things for introspection; however, what are some good examples of how they are used?
- Why isn't some form of macroexpansion provided in DrScheme? I would think that macroexpansion is something that students would struggle with and which they would appreciate tool support for.

