Hi, I have read Graham's "On Lisp". That, and my background in Java and Haskell programming were the main reasons I was drawn to Clojure. Based on that article and others like it I had the impression that program transformations like the one I suggested were relatively easy in homoiconic languages like Clojure and macros seem to be the tool to do it.
I guess what I'm really looking for now is the "how". Mark. On May 12, 1:54 pm, Sean Devlin <francoisdev...@gmail.com> wrote: > 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 -~----------~----~----~----~------~----~------~--~---