So you make judgements with the source code of my my_dumb_fun
. This is to say, the scope inference about the do
block is much more difficult. (I am not aware what the source code of the Threads.lock
function is).
Therefore, if the circumstance is like this, I cannot make a deterministic inference
julia> function modify_a_randomly(af)
rand() > .5 && return
af()
end;
julia> for i = 1:5
a = -10i
modify_a_randomly() do
a = 10i
end
println("i = $i, a = $a")
end
i = 1, a = 10
i = 2, a = -20
i = 3, a = 30
i = 4, a = -40
i = 5, a = 50