Scala macros - what are they, how do they work & who uses them

Adam Warski

12 Sep 2013.0 minutes read

Macros are a brand new feature of Scala 2.10. In the presentation I would like to explain why were they added to the language,
show step by step how to write your own simple macro and show some libraries, which already use macros to implement functionalities,
which were not possible before.

Macros are one of the new features in Scala 2.10. So far they are marked as experimental,
but I think nobody has doubts that they will stay there for good. Introducing macros was quite controversial, as Scala isn't
a "lean" language already, but I think it was worth it.

Macro is simply a Scala program, executed at compile-time, which manipulates the AST of our program. While we probably will mostly
write macros when creating a library of a framework, rather than in day-to-day work (hopefully!), for sure it is good to know
what are the mechanisms behind them.

In the presentation, I would firstly like to show step-by-step how to write a simple macro and how does it work. In the second part
I will present libraries, which already use macros (but without implementation details), such as ScalaMock,
Expecty, Slick or or my own, MacWire.

Slides

Video

Blog Comments powered by Disqus.