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/manual.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -373,6 +373,7 @@ DocTestSetup = quote
373
373
@resumable function arrays_of_tuples()
374
374
for u in [[(1,2),(3,4)], [(5,6),(7,8)]]
375
375
for i in 1:2
376
+
local val
376
377
let i=i
377
378
val = [a[i] for a in u]
378
379
end
@@ -413,4 +414,4 @@ DocTestSetup = nothing
413
414
- In a `try` block only top level `@yield` statements are allowed.
414
415
- In a `catch` or a `finally` block a `@yield` statement is not allowed.
415
416
- An anonymous function can not contain a `@yield` statement.
416
-
- If a `FiniteStateMachineIterator` object is used in more than one `for` loop, only the `state` variable is reinitialised. A `@resumable function` that alters its arguments will use the modified values as initial parameters.
417
+
- If a `FiniteStateMachineIterator` object is used in more than one `for` loop, only the `state` variable is reinitialised. A `@resumable function` that alters its arguments will use the modified values as initial parameters.
@@ -111,27 +132,53 @@ function transform_slots(expr, symbols)
111
132
expr
112
133
end
113
134
114
-
"""
115
-
Function that handles `let` block
116
-
"""
117
-
functiontransform_slots_let(expr::Expr, symbols)
118
-
@capture(expr, let vars_; body_ end)
119
-
locals =Set{Symbol}()
120
-
(isa(vars, Expr) && vars.head==:(=)) ||error("@resumable currently supports only single variable declarations in let blocks, i.e. only let blocks exactly of the form `let i=j; ...; end`. If you need multiple variables, please submit an issue on the issue tracker and consider contributing a patch.")
121
-
sym = vars.args[1].args[2].value
122
-
push!(locals, sym)
123
-
vars.args[1] = sym
124
-
body =postwalk(x->transform_let(x, locals), :(begin$(body) end))
# (isa(vars, Expr) && vars.head==:(=)) || error("@resumable currently supports only single variable declarations in let blocks, i.e. only let blocks exactly of the form `let i=j; ...; end`. If you need multiple variables, please submit an issue on the issue tracker and consider contributing a patch.")
142
+
# sym = vars.args[1].args[2].value
143
+
# push!(locals, sym)
144
+
# vars.args[1] = sym
145
+
# body = postwalk(x->transform_let(x, locals), :(begin $(body) end))
146
+
# :(let $vars; $body end)
147
+
#end
148
+
149
+
functiontransform_let(expr)
150
+
expr isa Expr ||return expr
151
+
expr.head ===:block&&return expr
152
+
#@info "inside transform let"
153
+
@capture(expr, let arg_; body_; end) ||return expr
154
+
#@info "captured let"
155
+
#arg |> dump
156
+
#@info expr
157
+
#@info arg
158
+
#error("ASds")
159
+
res =quote
160
+
let
161
+
local$arg
162
+
$body
163
+
end
164
+
end
165
+
#@info "emitting $res"
166
+
res
167
+
#expr.head === :. || return expr
168
+
#expr = expr.args[2].value in symbols ? :($(expr.args[2].value)) : expr
126
169
end
127
170
128
171
"""
129
172
Function that replaces a variable `_fsmi.x` in an expression by `x` where `x` is a variable declared in a `let` block.
130
173
"""
131
-
functiontransform_let(expr, symbols::Set{Symbol})
174
+
functiontransform_local(expr)
132
175
expr isa Expr ||return expr
133
-
expr.head === :. ||return expr
134
-
expr = expr.args[2].value in symbols ? :($(expr.args[2].value)) : expr
0 commit comments