init snippets
This commit is contained in:
commit
cc9255ae51
5 changed files with 137 additions and 0 deletions
21
std/macro.scala
Normal file
21
std/macro.scala
Normal file
|
@ -0,0 +1,21 @@
|
|||
//> using scala 3.4.0
|
||||
|
||||
import scala.quoted.*
|
||||
|
||||
inline def printTree[A](inline x: A) = ${printTreeImpl[A]('x)}
|
||||
|
||||
private def printTreeImpl[A](x: Expr[A])(using Quotes) = {
|
||||
import quotes.reflect.*
|
||||
def print0(t: Term): Unit = {
|
||||
t match {
|
||||
case Inlined(_, _, n) =>
|
||||
print0(n)
|
||||
case Lambda(vals, body) =>
|
||||
println(s"Lambda body ${body}")
|
||||
case o =>
|
||||
println(s"Lambda body ${o}")
|
||||
}
|
||||
}
|
||||
print0(x.asTerm)
|
||||
'{()}
|
||||
}
|
3
std/newInstance.scala
Normal file
3
std/newInstance.scala
Normal file
|
@ -0,0 +1,3 @@
|
|||
//> using scala 3.3.4
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue