Is it possible to generate a new class with macro in Dotty, Scala 3 ?
Zlaja
Currently in Dotty there is only (kind of) def macros. Currently there is no (kind of) macro annotations, which could generate a new member, new class etc.
For generation of a new member, new class etc. you can use
Scalameta (without or with SemanticDB, Scalafix [see also] depending on whether such generation is just syntactic or semantic), which works at the time before compile time (source generation), or
a compiler plugin, which works at compile time.
Let me remind you that even in Scalac the ability to generate a new member, new class etc. also appeared not from the very beginning. Such functionality (macro annotations) appeared as Macro Paradise compiler plugin to Scalac.
I can't exclude that somewhen somebody will write something like Macro Paradise for Dotty. It's too early for that, it's only feature-freeze for Dotty now, even language syntax (for example) and standard library keep changing now (there is also list of libraries that are testing their ability to work with Dotty, for example currently no Scalaz/Cats are there).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With