You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/lectures/lecture_07/lecture.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,7 @@ CodeInfo(
75
75
```
76
76
77
77
::: info Scope of eval
78
-
`eval` function is always evaluated in the global scope of the `Module` in which the macro is called (note that there is that by default you operate in the `Main` module). Moreover, `eval` takes effect **after** the function has been has been executed. This can be demonstrated as
78
+
`eval` function is always evaluated in the global scope of the `Module` in which it is called (note that there is that by default you operate in the `Main` module). Moreover, `eval` takes effect **after** the function has been has been executed. This can be demonstrated as
79
79
```julia
80
80
add1(x) = x + 1
81
81
function redefine_add(x)
@@ -87,9 +87,9 @@ CodeInfo(
87
87
88
88
julia> redefine_add(1)
89
89
0
90
-
91
90
```
92
91
92
+
93
93
Macros are quite tricky to debug. Macro `@macroexpand` allows to observe the expansion of macros. Observe the effect as
94
94
```julia
95
95
@macroexpand@replace_sin(cosp1(x) =1+sin(x))
@@ -160,7 +160,6 @@ end
160
160
```
161
161
(the `@showarg(1 + 1, :x)` raises an error, since `:(:x)` is of Type `QuoteNode`).
162
162
163
-
164
163
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.
0 commit comments