[gambit-list] Debugging define-macros

Guillaume Cartier gcartier at jazzscheme.org
Fri Oct 26 09:52:49 EDT 2007


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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20071026/ddc6e4fc/attachment.htm>


More information about the Gambit-list mailing list