This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
* Per Bothner [2010-08-12 21:37] writes: > So my question is: What do you need macro-expand for? The main use I > can think > of is when debugging macros. Note that the --debug-print-expr command-line > option prints out "expanded" syntax, though the syntax isn't actually valid > Scheme - just a pretty-printed form of the Expression tree. Below is the code for a simple macroexpand that uses the first stage of the compiler and turns the AST back to a s-expressions which are hopefully more readable than the debug dumps. Unfortunately, some fields in the IfExps class are private so we can't do that for ifs. Another issue are resolved functions in the AST that can't be easily mapped back to the source names. Example usage: (macroexpand '(do () (#f))) => (let ((%do%loop #!undefined)) (begin (set %do%loop (lambda () (If (Apply (Ref/45072/Declaration[applyToArgs/1]) (Ref/45071/Declaration[not/181]) (Quote #f)) (Apply line:1:15 (Ref/45076/Declaration[applyToArgs/1]) (Ref/45075/Declaration[%do%loop/7327])) (Quote )))) (%do%loop))) With exported fiels in IfExps the results looks so: (let ((%do%loop #!undefined)) (begin (set %do%loop (lambda () (if (not #f) (%do%loop) (quote )))) (%do%loop))) The pretty printer doesn't turn quote back to ' which would improve readability and it's even worse for backquote. Note also that nothing is printed for '#!void. Helmut
Attachment:
macroexpand.scm
Description: application/emacs-lisp
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |