[plt-scheme] how to debug expansions to top-level forms?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Thu Jun 26 21:18:42 EDT 2003

At Thu, 26 Jun 2003 21:05:43 -0400, Eli Barzilay wrote:
> On Jun 26, Robby Findler wrote:
> > Don't forget the caveat that repeated expand-once's is not the same
> > thing as calling expand.
> 
> Yeah, I should have mentioned that.  (Though IIRC, I don't think that
> there was an example of how things would behave differently.)

I don't fully understand how expand-once is different; all I know is
that there is information involved in expansion that isn't saved when
expand-once'ing but is saved when expand itself iterates internally
(Matthew and I talked about it a while back and he agreed that it would
be possible to make an expand-once that worked properly, but that's the
last I heard about it; FWIW, I think that's a key piece missing from
mzscheme for building a good macro programming environment in drscheme
(aka built in excuse :))

Anyways, I'm sure that there is a simpler and more illustrative example
of this general problem. Still, here's an example I came up with.
expand produces the right answer and 5 expand-once's doesn't.

(define x 2)

(define-syntax (m stx)
  (syntax x))

(define-syntax (n stx)
  (syntax-case stx ()
    [(_ b)
     (syntax (let-syntax ([x (lambda (stx) (syntax 1))]) (list x b)))]))

(expand #'(n (m)))

(expand-once (expand-once (expand-once (expand-once (expand-once #'(n (m)))))))

Robby


Posted on the users mailing list.