On Tue, Oct 29, 2013 at 4:20 AM, Peter Bex <[email protected]> wrote:

> On Tue, Oct 29, 2013 at 12:39:10AM -0700, Casey Rodarmor wrote:
> > Hi chickenemers,
>
> Hello Casey,
>
> > I would like to read a file containing macro definitions and a source
> file,
> > and output the source file after macro expansion, but before evaluation.
> >
> > Is there an easy way to do this? Like with some mysterious flag to csi or
> > csc that just outputs its macro-expanded input?
>
> You can try csc -debug 2, which will show the "canonicalized" output.
> It will expand all macros and some surrounding cruft that's added
> by the compiler for various reasons, but it should be the easiest
> way to show macro expansion.
>

Awesome, thanks! That's exactly what I was hoping for. There's a little bit
of cruft, but that's easy to deal with.


> Of course, another classic trick is to put a quote in front of the
> expansion code and print the result.  This will work fine from the
> interpreter as well:
>
> (define-syntax foo
>   (syntax-rules ()
>    ((foo) '(+ 1 1))))
>
> (print (foo))
> ;; Or, to see the expression in context:
> (print `(* ,(foo) 10))
>

Forgive my ignorance, but wouldn't that prevent recursive macro expansion?


>
> Cheers,
> Peter
> --
> http://www.more-magic.net
>
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to