5 ms·
What percentage of the techniques in this book are also applicable to Clojure programming? I don't know a lot about how the two macro systems differ.
by thurn 13y ago
What percentage of the techniques in this book are also applicable to Clojure programming? I don't know a lot about how the two macro systems differ.
- nickik 13y agoA lot of it. Clojure has a Common Lisp like macro system. There are some slight changes where clojure tried to make things a little simple, and the syntax is a lot diffrent. I think there are people on the internet who have implmented most of the example in clojure.
- AeroNotix 13y agoNo reader macros, though.
- arohner 13y agoOn Lisp is great for learning about macros, and what is possible. That being said, what is idiomatic in CL is not necessarily idiomatic clojure. For example, pg tends to like anaphoric macros, (http://en.wikipedia.org/wiki/Anaphoric_macro http://en.wikipedia.org/wiki/Anaphoric_macro), while Clojure tends to eschew them.
- oskarth 13y agoHave a look at http://thinkrelevance.com/blog/tags/on-lisp http://thinkrelevance.com/blog/tags/on-lisp to see Stuart Halloway going through On Lisp in Clojure.
- chongli 13y agoA fair amount of the examples involve mutation; a practice that Clojure discourages. A lot of the macros are very instructive, however.
- brudgers 13y agoIndeed, On Lisp has an excellent discussion of mutation and its use in programs written in a functional style. In discussing destructive functions, Graham describes the ways in which they can be used with reasonable safety - e.g. immediately mutating a list newly created by a mapping function. The reasons one might do so in Clojure are likely to bear similarity to those provided by Graham - speed and memory - despite the vastly greater resources of today's computers versus those of 1991.
- chongli 13y agoVery good point. Mutation is extremely useful when birthing a new data structure; this is a time when it's not yet visible to the rest of the system so the danger of sharing intermediate state does not occur. Clojure has a very elegant facility for dealing with this particular scenario: http://clojure.org/transients http://clojure.org/transients