Today I Learned

hashrocket A Hashrocket project

Expose Internal Representation

Elixir is a language that has strong support for metaprogramming. It provides easy access to an internal representation of the code in the form of an Abstract Syntax Tree (AST) using maps and keyword lists. The quote macro is used to expose this internal representation.

> quote do: 2 * 2
{:*, [context: Elixir, import: Kernel], [2, 2]}
> quote do: 2 * 2 == 4
{:==, [context: Elixir, import: Kernel],
 [{:*, [context: Elixir, import: Kernel], [2, 2]}, 4]}

source

See More #elixir TILs
Looking for help? At Hashrocket, we 💜 Elixir! From our many Elixir client projects, to sponsoring the Chicago Elixir Meetup, to the source code for this application, we are invested in this community. Contact us today to talk about your Elixir project.