Essentially I want to implement the equivalent of ...
# getting-started
g
Essentially I want to implement the equivalent of this:
Copy code
def eval(e: Expression): AST = e match {
  case Literal(value) => q"$value"
  case Attribute(name) => q"row.get($name)"
  case Add(left, right) => q"${eval(left)} + ${eval(right)}"
}
i
What's the difference between this and Kotlin string interpolation?
g
String interpolation happens at runtime Scala quasi-quotes don't produce a value, but a typed AST you can compile and evaluate Codegen like this is critical for performance in compilers and expression evaluators like the query engines in databases
You also get free optimization by the compiler since the result is an AST and the compiler can further optimize whatever tree is produced if possible
i
Got it. Thanks for explaining. Looks interesting.