chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Print source after macro expansion?


From: Casey Rodarmor
Subject: Re: [Chicken-users] Print source after macro expansion?
Date: Tue, 29 Oct 2013 04:36:30 -0700

On Tue, Oct 29, 2013 at 4:20 AM, Peter Bex <address@hidden> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]