Skip to content

Commit ff43ecc

Browse files
committed
some polishing
1 parent 6849d2f commit ff43ecc

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

docs/src/lecture_07/lecture.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -398,32 +398,25 @@ module Exfiltrator
398398

399399
const environment = Dict{Symbol, Any}()
400400

401-
add_variable!(name::Symbol, value) = environment[name] = value
402-
403-
function add_variables!(d::Dict)
401+
function copy_variables!(d::Dict)
402+
foreach(k -> delete!(environment, k), keys(environment))
404403
for (k, v) in d
405-
add_variable!(k, v)
404+
environment[k] = v
406405
end
407406
end
408407

409-
function reset!()
410-
foreach(k -> delete!(environment, k), keys(environment))
411-
end
412-
413408
macro exfiltrate()
414409
v = gensym(:vars)
415410
quote
416-
reset!()
417411
$(v) = $(esc((Expr(:locals))))
418-
add_variables!($(v))
412+
copy_variables!($(v))
419413
end
420414
end
421415

422-
export @exfiltrate
423-
424416
end
425417
```
426418

419+
Test it to
427420
```julia
428421
using Main.Exfiltrator: @exfiltrate
429422
let

0 commit comments

Comments
 (0)