[gambit-list] Debugging define-macros

Christopher Diggins cdiggins at gmail.com
Fri Oct 26 10:45:16 EDT 2007


Thank you very much for your prompt help Guillaume and David.

- Christopher

On 10/26/07, Guillaume Cartier <gcartier at jazzscheme.org> wrote:
> While reading my post I noticed that (pp foo) will not have the macros
> expanded in the compiled version. Of course, the Gambit compiler preserves
> the copy of the source code *before* doing macro expansions so it is exactly
> as in the source file. Sorry about that. Guess what that means is that the
> interpreter is your other friend ;)
>
>
>
> On 10/26/07, Guillaume Cartier <gcartier at jazzscheme.org> wrote:
> >
> > Your friends here are lambda and pp. Gambit will always expand macros
> inside a lambda so if you have file x.scm containing :
> >
> > ------------
> >
> >
> > (define-macro (when test body)
> >   `(if ,test
> >        (begin
> >          , at body)))
> >
> > (define (foo x)
> >   (when (= x 0)
> >     (write 'yo)))
> > ------------
> >
> > you can do the following
> >
> > Gambit v4.0.0
> >
> > > (load "x")
> > "C:\\Jazz\\dev\\jazz\\x.scm"
> > > (pp foo)
> > (lambda (x) (if (= x 0) (begin write 'yo)))
> > >
> > alternatively, if your code is compiled, I suggest always compiling it
> with -debug that adds no runtime penalty and keeps the source code so you
> can do
> >
> >
> > C:\Jazz\dev\jazz>gsc -debug x
> >
> > C:\Jazz\dev\jazz>gsc
> > Gambit v4.0.0
> >
> > > (load "x")
> > "C:\\Jazz\\dev\\jazz\\x.o1"
> > > (pp foo)
> > (##lambda (x) (when (= x 0) (write 'yo)))
> > >
> >
> > Guillaume
> >
> >
> > On 10/26/07, Christopher Diggins <cdiggins at gmail.com > wrote:
> > > I was wondering if anyone could suggest a method of debugging
> > > "define-macro" expressions so that I can see what is actually being
> > > generated by the macro system (e.g. by preventing evaluation of the
> > > resulting macro, and printing it)? Otherwise I get a cryptic messages
> > > like "unbound unquote", and "ill-formed expression", but without any
> > > hints what is causing the grief in the generated code.
> > >
> > > Thanks,
> > > Christopher Diggins
> > > _______________________________________________
> > > Gambit-list mailing list
> > > Gambit-list at iro.umontreal.ca
> > >
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
> > >
> > >
> >
> >
>
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
>



More information about the Gambit-list mailing list