Erlang metaprogramming made easy


By Erlang Central | Published: March 26, 2012



To generate Erlang code dynamically, you have until now had two choices: you could either create plain tuples according to the “abstract format” as generated by erl_parse (which is messy and has many special cases to keep in mind), or you could use the API functions in the erl_syntax module (which offer more abstraction, but can get pretty verbose). This talk will present the missing ingredient; a library allowing you to use template strings with metavariables, both for generating and matching on abstract syntax trees. As examples, I will show how we have used this at Klarna to implement a small domain-specific language for business logic, and demonstrate how you too can easily write a parse transform and even implement your own DSL that compiles to Beam code.
Talk objectives: Blowing a few minds.
Target audience: Anyone who wants to generate Erlang modules at run-time, for example for implementing a DSL or a parse transform.
Download Presentation Download

Speakers:

  • Richard Carlsson

    Father of eunit, edoc and try-catch
    Klarna AB

    Richard Carlsson has been deeply involved with Erlang since the mid-nineties. He was one of the original members of the High-Performance Erlang group at Uppsala University, and has contributed to many parts of the standard libraries, the Erlang compiler, runtime system, and the language itself. Among other things, he is the author of Erlang's 'EDoc' documentation system and the 'EUnit' unit testing framework, and he is one of the authors of the book Erlang and OTP in Action.

    Twitter: @rich_4711

    Homepage


    Richard Carlsson


Follow Erlang Central:


Have an Erlang Question?

Reach out to the Erlang community





Tags