Skip to content

Commit 3c19470

Browse files
committed
Remove scala.quoted.util.Var from the library
This is a nice abstration but it is not ablolutely required. It would fit nicely in an external library.
1 parent 70bcb28 commit 3c19470

File tree

2 files changed

+19
-50
lines changed

2 files changed

+19
-50
lines changed

library/src-bootstrapped/scala/quoted/util/Var.scala

Lines changed: 0 additions & 50 deletions
This file was deleted.

tests/run-staging/staged-streams_1.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,3 +680,22 @@ object Test {
680680
println(run(test10()))
681681
}
682682
}
683+
684+
sealed trait Var[T] {
685+
def get(using qctx: QuoteContext): Expr[T]
686+
def update(e: Expr[T])(using qctx: QuoteContext): Expr[Unit]
687+
}
688+
689+
object Var {
690+
def apply[T: Type, U: Type](init: Expr[T])(body: Var[T] => Expr[U])(using qctx: QuoteContext): Expr[U] = '{
691+
var x = $init
692+
${
693+
body(
694+
new Var[T] {
695+
def get(using qctx: QuoteContext): Expr[T] = 'x
696+
def update(e: Expr[T])(using qctx: QuoteContext): Expr[Unit] = '{ x = $e }
697+
}
698+
)
699+
}
700+
}
701+
}

0 commit comments

Comments
 (0)