19. I
• Takes several parameter lists
First comes a single
parameter, of type
Context
20. I
• Takes several parameter lists
Macro definition
Next, followed by a list of
parameters that have the
same names as the macro
definition parameters
21. I
• The original macro parameter has
• type T
• A macro implementation parameter has
• type c.Expr[T]
22. Q
• q"..." string interpolators that build code
• Unnecessary to directly implement the AST
• To use the quasiquotes from the macro, just write
import c.universe._
23. Q
• Using the showRaw, it is possible to see the AST
24. Goodness
• The hard to comprehend notion of meta
programming
• def macros are similar to the concept of a typed
method call
47. Current state
• Optimized towards compiler developers, not library
users
Complicated
48.
49. Scala 2.12 (plan)
• Not introduce new features
• Bugfixes and stability improvements
• Mention later why reason
50. scala.meta
• A new experimental API for metaprogramming
• F
51. scala.meta
• Implemented in a library shipped separately from
the official Scala distribution
• The first milestone release is scheduled for this fall
52. The goal of scala.meta
• Metaprogramming easy
• New API is going to greatly simplify writing
macros
• Not require knowledge of compiler internals
53. Language model
• All represented with trees
Types
Modifiers
…
Names
Trees
scala.meta
Terms
Symbols
54. Language model
• Keeps all the information about the program
• Comments also remain
• No information is lost anymore