File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,10 @@ keyword arguments. Among others, this includes
90
90
91
91
Settings like `ntasks`, `chunksize`, and `split` etc. can be used to tune the scheduling policy (if the selected scheduler supports it).
92
92
93
+ Note that the assignment is hoisted above the loop body which means that the scope is *not*
94
+ the scope of the loop (even though it looks like it) but rather the scope *surrounding* the
95
+ loop body. (`@macroexpand` is a useful tool to inspect the generated code of the `@tasks`
96
+ block.)
93
97
"""
94
98
macro set (args... )
95
99
error (" The @set macro may only be used inside of a @tasks block." )
146
150
# ...
147
151
end
148
152
```
153
+
154
+ The right hand side of the assignment is hoisted outside of the loop body and captured
155
+ as a closure used to initialize the task local value. This means that the scope of the
156
+ closure is *not* the scope of the loop (even though it looks like it) but rather the
157
+ scope *surrounding* the loop body. (`@macroexpand` is a useful tool to inspect the
158
+ generated code of the `@tasks` block.)
149
159
"""
150
160
macro $ (Symbol (" local" ))(args... )
151
161
error (" The @local macro may only be used inside of a @tasks block." )
You can’t perform that action at this time.
0 commit comments