[plt-scheme] Where is macroexpand in PLT Scheme?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Tue Nov 11 17:03:32 EST 2003

At Tue, 11 Nov 2003 13:59:30 -0800 (PST), Bill Clementson wrote:
> --- Robby Findler <robby at cs.uchicago.edu> wrote:
> > At Tue, 11 Nov 2003 13:00:32 -0800 (PST), Bill
> > Clementson wrote:
> > > The expansion seems to do an "expand" rather than
> > an
> > > "expand-to-top-level". 
> > 
> > Probably because I've never heard of
> > expand-to-top-level. :)
> Oops, I meant expand-to-top-form :-(
> > Technically, it uses
> > expand-syntax-top-level-with-compile-time-evals.
> > Details on it are in Help Desk.
> My point was that the information that is displayed is
> similar to the information displayed when you do a
> (syntax-object->datum (expand '(some-macro
> some-params))) while I think a more meaningful
> expansion would be the result of (syntax-object->datum
> (expand-to-top-form '(some-macro some-params)))

That doesn't do the right thing. Consider programs like this:

(define-syntax (m stx)

(m 1)

You need to fully expand the first one and then use it to expand the
second. That's what the long named thing above does.

But, in general, I agree with you. Ryan Culpepper is working on
building this poor little Expander language into a full PDE for macro
writers, but we're still a ways away from that, and what is there is
what is currently easy.

FWIW, anytime a syntax object is returned in the REPL, you get that
turn down arrow, so you can use that in other language levels.

> When I click around in the expansion, the "Source" in
> the right-hand side is always either colorer.ss or #f.
> Can you suggest some source file in the PLT collects
> directories that I can load that will show some other
> value in "Source"? What is "Source" meant to represent
> anyhow? I thought it would be the source file where
> the macro is defined.  

It is defined to be the thing that got passed to read-syntax when the
syntax object was constructed. Often the filename of the file where the
definitions (or the editor object in the case of DrScheme).


Posted on the users mailing list.