Skip to content

Commit d1ad491

Browse files
committed
Added refs to lecture 7.
1 parent 76d0512 commit d1ad491

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/src/lecture_07/lecture.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ end
164164

165165
Observe that macro dispatch is based on the types of AST that are handed to the macro, not the types that the AST evaluates to at runtime.
166166

167-
## Notes on quotation
167+
## [Notes on quotation](@id lec7_quotation)
168168
In the previous lecture we have seen that we can *quote a block of code*, which tells the compiler to treat the input as a data and parse it. We have talked about three ways of quoting code.
169169
1. `:(quoted code)`
170170
2. Meta.parse(input_string)
@@ -239,7 +239,7 @@ Instead, when a macro is given an expression with $ in it, it assumes you're goi
239239
run(`touch $(filename)`)
240240
```
241241

242-
## Macro hygiene
242+
## [Macro hygiene](@id lec7_hygiene)
243243
Macro hygiene is a term coined in 1986. The problem it addresses is following: if you're automatically generating code, it's possible that you will introduce variable names in your generated code that will clash with existing variable names in the scope in which a macro is called. These clashes might cause your generated code to read from or write to variables that you should not be interacting with. A macro is hygienic when it does not interact with existing variables, which means that when macro is evaluated, it should not have any effect on the surrounding code.
244244

245245
By default, all macros in Julia are hygienic which means that variables introduced in the macro have automatically generated names, where Julia ensures they will not collide with user's variable. These variables are created by `gensym` function / macro.

0 commit comments

Comments
 (0)