Skip to content

Commit 2c2c8cf

Browse files
committed
Update staging docs
1 parent 1e0475c commit 2c2c8cf

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/docs/reference/metaprogramming/staging.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ The framework as discussed so far allows code to be staged, i.e. be prepared
6060
to be executed at a later stage. To run that code, there is another method
6161
in class `Expr` called `run`. Note that `$` and `run` both map from `Expr[T]`
6262
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.
6565

6666
```scala
6767
package scala.quoted.staging
@@ -99,17 +99,17 @@ scala -with-compiler -classpath out Test
9999
Now take exactly the same example as in [Macros](./macros.md). Assume that we
100100
do not want to pass an array statically but generate code at run-time and pass
101101
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
104104
to get a source-like representation of the expression.
105105

106106
```scala
107-
import scala.quoted.staging._
107+
import scala.quoted._
108108

109109
// 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)
111111

112-
val f: Array[Int] => Int = run {
112+
val f: Array[Int] => Int = staging.run {
113113
val stagedSum: Expr[Array[Int] => Int] =
114114
'{ (arr: Array[Int]) => ${sum('arr)}}
115115
println(stagedSum.show) // Prints "(arr: Array[Int]) => { var sum = 0; ... }"

0 commit comments

Comments
 (0)