Macros are definitely the tool to do this. Take a look here at Paul Graham's "The Roots of Lisp". In it you'll get an idea of why eval is so powerful, and why macros are exactly the tool for the job you're thinking of.
http://lib.store.yahoo.net/lib/paulgraham/jmc.ps I'll let someone else answer "how" with respect to Clojure. Sean On May 11, 11:42 pm, Mark Reid <mark.r...@gmail.com> wrote: > Hi, > > I'm quite new to macros so forgive me if this is a naïve question, but > is it possible to write macros that are applied to an entire Clojure > program? > > The reason I ask is that, in other threads in this group, some simple > transformations to improve efficiency of Clojure programs were > mentioned. In particular, it seems converting `(+ 1 2 3)` to `(+ 1 (+ > 2 3))` can speed things up. Applying such a transformation to my own > code would be a mindless pattern matching job, and thus perfect for > automation. > > Any suggestions how I might write a Clojure program that takes as > input another Clojure program and outputs a third one that is > optimised but semantically equivalent to the input? Are macros the > right tool for the job in this case? > > Thanks, > > Mark. > --http://mark.reid.name --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---