Metaprogramming in Non-Lisps

Lisp certainly isn’t the only language family with metaprogramming facilities. C has a macro system that allows textual replacement as a preprocessing step at the start of compilation. C++ has a complex and powerful template metaprogramming feature that’s itself Turing-complete. Plenty of dynamic languages, like JavaScript, Python, and Ruby, have eval functions that acts on strings to produce a result. Ruby, in particular, has quite a few nice features, and Scala’s macro system even allows you to manipulate the parse tree! But here’s fair warning: once you’ve experienced Clojure’s macros, you may not want to go back.

You may notice that in this book, sometimes I’ll refer to Clojure, and sometimes to Lisp in general (since Clojure is part of the Lisp family of languages). This shouldn’t be too confusing, but let’s take a moment to clarify, just to make sure. When I talk about Lisp, the advice will apply across all the major Lisps (including Clojure, Scheme, and Common Lisp). Elixir is an interesting edge case: it’s not quite a Lisp, but its macro system sure walks and talks like one. But just because I mention Clojure specifically doesn’t mean that the advice only applies to Clojure. It may well apply in other Lisps too, but not necessarily.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.253.210