Skip to content

Commit beba63a

Browse files
authored
Merge pull request #7165 from dotty-staging/add-dotty-staging.g8
Add dotty-staging.g8 in the staging documentation
2 parents b151414 + eb7786c commit beba63a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

docs/docs/reference/metaprogramming/staging.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ def run[T](expr: given QuoteContext => Expr[T]) given (toolbox: Toolbox): T = ..
7171
def withQuoteContext[T](thunk: given QuoteContext => T) given (toolbox: Toolbox): T = ...
7272
```
7373

74+
## Create a new Dotty project with staging enabled
75+
76+
```shell
77+
sbt new lampepfl/dotty-staging.g8
78+
```
79+
80+
From [lampepfl/dotty-staging.g8](https://github.com/lampepfl/dotty-staging.g8).
81+
82+
It will create a project with the necessary dependencies and some examples.
83+
7484
## Example
7585

7686
Now take exactly the same example as in [Macros](./macros.md). Assume that we
@@ -84,7 +94,7 @@ to get a source-like representation of the expression.
8494
import scala.quoted.staging._
8595

8696
// make available the necessary toolbox for runtime code generation
87-
delegate for Toolbox = Toolbox.make(getClass.getClassLoader)
97+
given as Toolbox = Toolbox.make(getClass.getClassLoader)
8898

8999
val f: Array[Int] => Int = run {
90100
val stagedSum: Expr[Array[Int] => Int] = '{ (arr: Array[Int]) => ${sum('arr)}}
@@ -99,11 +109,12 @@ Note that if we need to run the main (in an object called `Test`) after
99109
compilation we need make available the compiler to the runtime:
100110

101111
```shell
102-
sbt:dotty> dotr -classpath out -with-compiler Test
112+
dotc -with-compiler -d out Test.scala
113+
dotr -with-compiler -classpath out Test
103114
```
104115

105116
Or, from SBT:
106117

107118
```scala
108-
libraryDependencies += "ch.epfl.lamp" %% "dotty-compiler" % scalaVersion.value
119+
libraryDependencies += "ch.epfl.lamp" %% "dotty-staging" % scalaVersion.value
109120
```

0 commit comments

Comments
 (0)