File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
docs/docs/reference/metaprogramming Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,16 @@ def run[T](expr: given QuoteContext => Expr[T]) given (toolbox: Toolbox): T = ..
7171def 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
7686Now 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.
8494import 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
8999val 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
99109compilation 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
105116Or, from SBT:
106117
107118``` scala
108- libraryDependencies += " ch.epfl.lamp" %% " dotty-compiler " % scalaVersion.value
119+ libraryDependencies += " ch.epfl.lamp" %% " dotty-staging " % scalaVersion.value
109120```
You can’t perform that action at this time.
0 commit comments