Skip to content

Commit a4bdb4f

Browse files
nicolasstuckiliufengyun
authored andcommitted
Add supspension to macro docs
1 parent 9134d3f commit a4bdb4f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/docs/reference/metaprogramming/macros.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,19 @@ def defaultOfImpl(str: String): Expr[Any] = str match {
598598
// in a separate file
599599
val a: Int = defaultOf("int")
600600
val b: String = defaultOf("string")
601+
601602
```
602603

604+
### Defining a macro and using it in a single project
605+
It is possible to define macros and use them in the same project as the implementation of
606+
the macros does not depend on code in the file where it used. It might still depend
607+
on types and quoted code that refers to the use-site file.
608+
609+
To provide this functionality Dotty provides a transparent compilation mode were files that
610+
expand try to expand a macro but fail because the macro has not been compiled yet are suspended.
611+
If there are any suspended files when the compilation ends, the compiler will automatically restart
612+
compilation of the suspended files using the output of the previous (partial) compilation as macro classpath.
613+
In case all files are suspended due to cyclic dependencies the compilation will fail with an error.
614+
615+
603616
[More details](./macros-spec.md)

0 commit comments

Comments
 (0)