Skip to content

Commit

Permalink
Add note of separate compilation unit in macro's code example
Browse files Browse the repository at this point in the history
  • Loading branch information
mentegy committed May 22, 2018
1 parent 297e9fc commit 39a3360
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/docs/reference/principled-meta-programming.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,12 @@ program that calls `assert`.
'{ if !(~expr) then throw new AssertionError(s"failed assertion: ${~expr}") }
}

val program = {
val x = 1
Macros.assert(x != 0)
// has to be in a different compilation unit that depends on Macros
object App {
val program = {
val x = 1
Macros.assert(x != 0)
}
}

Inlining the `assert` function would give the following program:
Expand Down

0 comments on commit 39a3360

Please sign in to comment.