@@ -60,8 +60,8 @@ The framework as discussed so far allows code to be staged, i.e. be prepared
60
60
to be executed at a later stage. To run that code, there is another method
61
61
in class ` Expr ` called ` run ` . Note that ` $ ` and ` run ` both map from ` Expr[T] `
62
62
to ` T ` but only ` $ ` is subject to the PCP, whereas ` run ` is just a normal method.
63
- ` run ` provides a ` Quotes ` that can be used to show the expression in its scope.
64
- On the other hand ` withQuotes ` provides a ` Quotes ` without evaluating the expression.
63
+ ` scala.quoted.staging. run` provides a ` Quotes ` that can be used to show the expression in its scope.
64
+ On the other hand ` scala.quoted.staging. withQuotes` provides a ` Quotes ` without evaluating the expression.
65
65
66
66
``` scala
67
67
package scala .quoted .staging
@@ -99,17 +99,17 @@ scala -with-compiler -classpath out Test
99
99
Now take exactly the same example as in [ Macros] ( ./macros.md ) . Assume that we
100
100
do not want to pass an array statically but generate code at run-time and pass
101
101
the value, also at run-time. Note, how we make a future-stage function of type
102
- ` Expr[Array[Int] => Int] ` in line 6 below. Using ` run { ... } ` we can evaluate an
103
- expression at runtime. Within the scope of ` run ` we can also invoke ` show ` on an expression
102
+ ` Expr[Array[Int] => Int] ` in line 6 below. Using ` staging. run { ... }` we can evaluate an
103
+ expression at runtime. Within the scope of ` staging. run` we can also invoke ` show ` on an expression
104
104
to get a source-like representation of the expression.
105
105
106
106
``` scala
107
- import scala .quoted .staging . _
107
+ import scala .quoted ._
108
108
109
109
// make available the necessary compiler for runtime code generation
110
- given Compiler = Compiler .make(getClass.getClassLoader)
110
+ given staging . Compiler = staging. Compiler .make(getClass.getClassLoader)
111
111
112
- val f : Array [Int ] => Int = run {
112
+ val f : Array [Int ] => Int = staging. run {
113
113
val stagedSum : Expr [Array [Int ] => Int ] =
114
114
' { (arr : Array [Int ]) => $ {sum(' arr )}}
115
115
println(stagedSum.show) // Prints "(arr: Array[Int]) => { var sum = 0; ... }"
0 commit comments