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: Peter Bex
Subject: Re: [Chicken-users] Print source after macro expansion?
Date: Tue, 29 Oct 2013 12:20:11 +0100
User-agent: Mutt/1.4.2.3i

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.

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))

Cheers,
Peter
-- 
http://www.more-magic.net



reply via email to

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