|
|
|
|
|
by gamache
3906 days ago
|
|
Macros are the most powerful tool for making DSLs, which means they pop up in a lot of "specialized" niches, like web dev. You can make DSLs in other ways, but without the ability to inspect and decompose code at the per-token level, there are limitations to what can be done. Elixir macros are like Scheme macros; they're fully hygienic (no variable namespace issues), and they evaluate at compile time. The main difference is that Scheme's main syntax construction is the linked list, and Elixir uses a richer data structure, almost equivalent to JSON. Aside from the particular structure the macro's manipulating, the concepts are the same. Elixir macros are also used idiomatically to allow "smart" loading of modules, e.g. specifying additional code to run in the caller's context rather than the callee's. They fit nicely for this purpose. |
|
[1] https://groups.google.com/forum/#!topic/lisp-flavoured-erlan...
[2] http://devintorr.es/blog/2013/06/11/elixir-its-not-about-syn...
[3] http://c2.com/cgi/wiki?HomoiconicLanguages