Work in Progress

We are still in the process of writing the documentation for Scala 3. You can help us to improve the documentation.

Are you searching for the Scala 2 documentation?

Scala 3 Language Reference

Dropped: Scala 2 Macros

Language

The previous, experimental macro system has been dropped.

Instead, there is a cleaner, more restricted system based on two complementary concepts: inline and '{ ... }/${ ... } code generation. '{ ... } delays the compilation of the code and produces an object containing the code, dually ${ ... } evaluates an expression which produces code and inserts it in the surrounding ${ ... }. In this setting, a definition marked as inlined containing a ${ ... } is a macro, the code inside the ${ ... } is executed at compile-time and produces code in the form of '{ ... }. Additionally, the contents of code can be inspected and created with a more complex reflection API as an extension of '{ ... }/${ ... } framework.

  • inline has been implemented in Scala 3.
  • Quotes '{ ... } and splices ${ ... } has been implemented in Scala 3.
  • TASTy reflect provides more complex tree based APIs to inspect or create quoted code.

Contributors to this page: