Josef Wolf wrote:
I am trying to understand the defstruct macro from the "teach yourself
scheme in fixnum days" tutorial, which can be found in chapter 9 at
http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-11.html#node_chap_9
My first question is of a more generic type. For a better understanding
how macros work, I'd like to have a way to show what expansion a macro
would generate when it would be used. E.g., I'd like to do something
like
(show-expansion (defstruct tree height girth age leaf-shape leaf-color))
and get what the expansion of this macro would produce:
(begin
(define make-tree
(lambda fvfv
[ ... and so on ... ]
Use the trick from the inexplicable JRM's Syntax-rules Primer for the
Merely Eccentric[1], wrap the output with quote:
...
(let ((ff (map (lambda (f) (if (pair? f) (car f) f))
ff)))
`'(begin
; ^
(define ,(string->symbol
(string-append "make-" s-s))
...
[1]
http://www.xs4all.nl/~hipster/lib/scheme/gauche/define-syntax-primer.txt