|
|
|
|
|
by lectrick
4005 days ago
|
|
> but in Erlang you don't want to touch that feature with a ten foot pole. It's hairy and incredibly annoying to work with It's pretty much the exact opposite in Elixir. The only thing you really have to wrap your head around is the switch between the quoting context and the unquoting context... which is pretty much no different from understanding macros period. The definition syntax looks just like a method definition, except it's "defmacro" instead of "def", and the macro body receives an AST instead of (or in addition to) your usual arguments. But I'm probably not doing it justice... http://elixir-lang.org/getting-started/meta/macros.html https://pragprog.com/book/cmelixir/metaprogramming-elixir Here Dave Thomas creates a simple "returning" macro, you can just watch the screencast if you're feeling lazy:
http://pragdave.me/blog/2014/11/05/a-simple-elixir-macro/ |
|